Installation from Source ******************************************* In most cases, you should not need to build CUDA Quantum from source. For the best experience, we recommend using a container runtime to avoid conflicts with other software tools installed on the system. Note that `Singularity `__ or `Docker rootless mode `__ address common issue or concerns that are often the motivation for avoiding the use of containers. Singularity, for example, can be installed in a user folder and its installation does not require admin permissions; see :ref:`this section ` for more detailed instructions on how to do that. Our installation guide also contains instructions for how to :ref:`connect an IDE ` to a running container. If you do not want use a container runtime, we also provide pre-built binaries for using CUDA Quantum with C++. These binaries are built following the instructions in this guide and should work for you as long as your system meets the compatibility requirements listed under :ref:`Prerequisites `. To install them, please follow the instructions :ref:`here `. If you still want to build and install CUDA Quantum from source, you will need to ensure that all dependencies installed in the build and host system are compatible with your CUDA Quantum installation. The rest of this guide outlines specific compatibility requirements during the build and after installation, and walks through the installation steps. .. note:: The build described in this guide does not include the support for building the Python support for CUDA Quantum. For more information about using CUDA Quantum from Python, please take a look at :ref:`this page `. CUDA Quantum contains some components that are only included as pre-built binaries and not part of our open source repository. We are working on either open-sourcing these components or making them available as separate downloads in the future. Even without these components, almost all features of CUDA Quantum will be enabled in a source build, though some pieces may be less performant. At this time, the :ref:`multi-GPU state vector simulator ` backend will not be included if you build CUDA Quantum from source. .. _compatibility-prebuilt-binaries: Prerequisites ------------------------------------ The following pre-requisites need to be satisfied both on the build system and on the host system, that is the system where the built CUDA Quantum binaries will be installed and used. - Linux operating system. The instructions in this guide have been validated with the `AlmaLinux 8 image `__ that serves as the base image for the `manylinux_2_28 image `__, and should work for the operating systems CentOS 8, Debian 11 and 12, Fedora 38, OpenSUSE/SLED/SLES 15.5, RHEL 8 and 9, Rocky 8 and 9, and Ubuntu 22.04. Other operating systems may work, but have not been tested. - `Bash `__ shell. The CUDA Quantum build, install and run scripts expect to use `/bin/bash`. - `GNU C library `__. Make sure that the version on the host system is the same one or newer than the version on the build system. Our own builds use version 2.28. - CPU with either x86-64 (x86-64-v3 architecture and newer) or ARM64 architecture. Other architectures may work but are not tested and may require adjustments to the build instructions. - Needed only on the host system: NVIDIA GPU with Volta, Turing, Ampere, Ada, or Hopper architecture and `Compute Capability `__ 7+. Make sure you have the latest `drivers `__ installed for your GPU, and double check that the driver version listed by the `nvidia-smi` command is 470.57.02 or newer. We strongly recommend using a virtual environment for the build that includes *only* the tools and dependencies listed in this guide. If you have additional software installed, you will need to make sure that the build is linking against the correct libraries and versions. Build Dependencies ------------------------------------ In addition to the prerequisites listed above, you will need to install the following prerequisites in your build environment prior to proceeding with the build as described in the subsequent sections: - GNU C library: We currently statically link dependencies, in some cases including the standard libraries. We may revise that in the future. To use the current build configuration, please make sure you have the static version of the `GNU C library `__, including the POSIX Threads library, installed on your system. The necessary package(s) can usually be obtained via package manager for your distribution. - Python version 3.8 or newer: The Python interpreter is required (only) for some of the LLVM build scripts and the Python version used for the build does not have to match the version on the host system. - Common tools: `wget`, `git`, `unzip`. The commands in the rest of this guide assume that these tools are present on the build system, but they can be replaced by other alternatives (such as, for example, manually going to a web page and downloading a file/folder). The above prerequisites are no longer needed once CUDA Quantum is built and do not need to be present on the host system. .. note:: The CUDA Quantum build scripts and the commands listed in the rest of this document assume you are using `bash` as the shell for your build. In addition to installing the needed build dependencies listed above, make sure to set the following environment variables prior to proceeding: .. literalinclude:: ../../scripts/configure_build.sh :language: bash :dedent: :start-after: [>InstallLocations] :end-before: [`__ following the installation guide for your platform in the online documentation linked on that page. Within the tested AlmaLinux 8 environment, for example, the following commands install CUDA 11.8: .. literalinclude:: ../../scripts/configure_build.sh :language: bash :dedent: :start-after: [>CUDAInstall] :end-before: [cuQuantumInstall] :end-before: [cuTensorInstall] :end-before: [`__ for the installed CUDA version. The following instructions have been tested with `GCC-11 `__ as your toolchain for building CUDA Quantum. If you use a different compiler, we recommend using an OpenMP-enabled compiler. At this time, we actively test building with GCC 11 and 12, as well as with Clang 16. Other toolchains may be supported but have not been tested. Within the tested AlmaLinux 8 environment, for example, the following commands install GCC 11: .. literalinclude:: ../../scripts/configure_build.sh :language: bash :dedent: :start-after: [>gccInstall] :end-before: [ToolchainConfiguration] :end-before: [`__ and checkout the appropriate branch, tag, or commit. Note that the build scripts assume that they are run from within a git repository, and merely downloading the source code as ZIP archive hence will not work. From within the folder where you cloned the CUDA Quantum repository, run the following command to build CUDA Quantum: .. literalinclude:: ../../docker/build/assets.Dockerfile :language: bash :dedent: :start-after: [>CUDAQuantumBuild] :end-before: [`__. To do so, download the `makeself script(s) `__ and move the necessary files to install into a separate folder using the command .. literalinclude:: ../../docker/release/installer.Dockerfile :language: bash :dedent: :start-after: [>CUDAQuantumAssets] :end-before: [`__ linker, by default. While this linker should be a drop-in replacement for system linkers, in rare cases it may be necessary to use your own linker instead. You can configure CUDA Quantum to use an external linker setting the `NVQPP_LD_PATH` environment variable to point to it; for example `export NVQPP_LD_PATH=ld`. To enable C++ development in general, you should also make sure that the `C++ standard library `__ is installed and discoverable on your host system. CUDA Quantum supports the GNU C++ standard library (`libstdc++`), version 11 or newer. Other libraries may work but can cause issues in certain cases. The remaining sections in this document list additional runtime dependencies that are not included in the migrated assets and are needed to use some of the CUDA Quantum features and components. CUDA Runtime Libraries +++++++++++++++++++++++++++++++ To use GPU-acceleration in CUDA Quantum you will need to install the necessary CUDA runtime libraries. While not necessary, we recommend installing the complete CUDA toolkit like you did for the CUDA Quantum build. If you prefer to only install the minimal set of runtime libraries, the following commands, for example, install the necessary packages for the AlmaLinux 8 environment: .. literalinclude:: ../../scripts/configure_build.sh :language: bash :dedent: :start-after: [>CUDARTInstall] :end-before: [OpenMPIBuild] :end-before: [`__ or `RSH `__ to communicate with each node unless another resource manager, such as `SLURM `__, is used. Different MPI implementations are supported via a plugin infrastructure in CUDA Quantum. Once you have a CUDA-aware MPI installation on your host system, you can configure CUDA Quantum to use it by activating the necessary plugin. Plugins for OpenMPI and MPICH are included in CUDA Quantum and can be activated by setting the environment variable `MPI_PATH` to the MPI installation folder and then running the command .. code-block:: bash bash "${CUDA_QUANTUM_PATH}/distributed_interfaces/activate_custom_mpi.sh" If you use a different MPI implementation than OpenMPI or MPICH, you will need to implement the necessary plugin interface yourself prior to activating the plugin with the command above. .. TODO: For more information about building and activating a custom MPI plugin, see ...