Installing Qibo

The Qibo package comes with the following modules:


Installing with pip

The installation using pip is the recommended approach to install Qibo. We provide precompiled packages for linux x86/64, macosx 10.15 or greater and Windows for multiple Python versions.

Make sure you have Python 3.6 or greater, then use pip to install qibo with:

pip install qibo

The pip program will download and install all the required dependencies for Qibo.

Note

The pip packages for linux are compiled with CUDA support, so if your system has a NVIDIA GPU, Qibo will perform calculations on GPU.

Note

The pip packages for Windows do not provide the custom backend.

Installing from source

The installation procedure presented in this section is useful in two situations:

  • you need to install Qibo in an operating system and environment not supported by the pip packages (see Installing with pip).

  • you have to develop the code from source.

In order to install Qibo from source, you can simply clone the GitHub repository with

git clone https://github.com/Quantum-TII/qibo.git
cd qibo

then proceed with the installation of requirements with:

pip install -r requirements.txt

Make sure your system has a GNU g++ >= 6 compiler. If you are working on macosx make sure the command c++ is clang >= 11 and install the libomp library with brew install libomp command.

Optionally, you can use the CXX environment variable to set then compiler path. Similarly, the PYTHON environment variable sets the python interpreter path.

Note

If your system has a NVIDIA GPU, make sure TensorFlow is installed properly and runs on GPU, please refer to the official documentation.

In that case, you can activate GPU support for Qibo by:

  1. installing the NVCC compiler matching the TensorFlow CUDA version, see the CUDA documentation.

  2. exporting the CUDA_PATH variable with the CUDA installation path containing the cuda compiler.

  3. make sure the NVCC compiler is available from CUDA_PATH/bin/nvcc, otherwise the compilation may fail. You can locate it with whereis nvcc and eventually link/copy to your CUDA_PATH/bin folder.

For example, TensorFlow 2.4 supports CUDA 11. After installing TensorFlow proceed with the NVCC 11 installation. On linux the installation path usually is /usr/local/cuda-11/.

Before installing Qibo do export CUDA_PATH=/usr/local/cuda-11.

Note that Qibo will not enable GPU support if points 1 and 2 are not performed.

Then proceed with the Qibo installation using pip

pip install .

or if you prefer to manually execute all installation steps:

# builds binaries
python setup.py build

# installs the Qibo packages
python setup.py install # or python setup.py develop

If you prefer to keep changes always synchronized with the code then install using the develop option:

pip install -e .
# or
python setup.py develop

Optionally, in order to run tests and build documentation locally you can install extra dependencies with:

pip install qibo[tests,docs]