Skip to content

Commit 73b3f62

Browse files
1tnguyenbettinaheim
authored andcommitted
Update docs to cover CUDA-aware MPI in more details (#945)
1 parent 7ad4947 commit 73b3f62

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

docs/sphinx/examples/python/bernstein_vazirani.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def bernstein_vazirani(qubit_count: int):
8383
required=False,
8484
default='',
8585
help='The target to execute the algorithm on.')
86+
parser.add_argument('--seed',
87+
type=int,
88+
required=False,
89+
default=0,
90+
help='The random seed to generate the secret string.')
8691
args = parser.parse_args()
8792

8893
# Depending on the available memory on your GPU, you can
@@ -94,6 +99,8 @@ def bernstein_vazirani(qubit_count: int):
9499
# a long time for the CPU-only backend to simulate 28+ qubits!
95100

96101
qubit_count = args.size
102+
if args.seed != 0:
103+
random.seed(args.seed)
97104
if args.target and not args.target.isspace():
98105
cudaq.set_target(args.target)
99106

python/README.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,46 @@ CUDA Quantum can be used to compile and run quantum programs on a CPU-only
3333
system, but a GPU is highly recommended and necessary to use the some of the
3434
simulators. The GPU-based simulators included in the CUDA Quantum Python wheels
3535
require an existing CUDA installation. Additionally, multi-GPU simulators
36-
require an existing MPI installation.
36+
require an existing CUDA-aware MPI installation.
3737

38-
In most cases, the CUDA and MPI dependencies can be installed via package
39-
manager. On Ubuntu 22.04, for example, the following commands install all
40-
optional CUDA dependencies:
38+
To install the necessary dependencies, we recommend using
39+
[Conda](https://docs.conda.io/en/latest/). If you are not already using Conda,
40+
you can install a minimal version following the instructions
41+
[here](https://docs.conda.io/projects/miniconda/en/latest/index.html).
42+
The following commands will create and activate a complete environment for
43+
CUDA Quantum with all its dependencies:
4144

4245
```console
43-
arch=x86_64 # set this to sbsa for ARM processors
44-
sudo apt-get update && sudo apt-get install -y wget
45-
wget -q https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/$arch/cuda-keyring_1.0-1_all.deb
46-
sudo dpkg -i cuda-keyring_1.0-1_all.deb && rm cuda-keyring_1.0-1_all.deb
47-
sudo apt-get update && sudo apt-get install -y cuda-toolkit-11.8
46+
conda create -y -n cuda-quantum python==3.10 pip
47+
conda install -y -n cuda-quantum -c "nvidia/label/cuda-11.8.0" cuda
48+
conda install -y -n cuda-quantum -c conda-forge mpi4py openmpi
49+
conda env config vars set -n cuda-quantum LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CONDA_PREFIX/envs/cuda-quantum/lib"
50+
conda run -n cuda-quantum pip install cuda-quantum
51+
conda activate cuda-quantum
4852
```
4953

50-
Detailed instructions for how to install the complete CUDA toolkit on different
51-
operating systems can be found in the [CUDA
52-
documentation](https://docs.nvidia.com/cuda/).
53-
54-
If you have several GPUs available but no MPI installation yet, we recommend
55-
taking a look at the [OpenMPI documentation](https://docs.open-mpi.org/)
56-
and installing [mpi4py](https://mpi4py.readthedocs.io/).
57-
On Ubuntu 22.04, for example, the following commands install the necessary MPI
58-
libraries:
54+
You must configure MPI by setting the following environment variables:
5955

6056
```console
61-
sudo apt-get update && sudo apt-get install -y libopenmpi-dev libpython3-dev gcc
62-
python3 -m pip install mpi4py
57+
export OMPI_MCA_opal_cuda_support=true OMPI_MCA_btl='^openib'
6358
```
6459

60+
*If you do not set these variables you may encounter a segmentation fault.*
61+
62+
**Important**: It is *not* sufficient to set these variable within the conda
63+
environment, like the commands above do for `LD_LIBRARY_PATH`.
64+
To avoid having to set them every time you launch a new
65+
shell, we recommend adding them to `~/.profile`
66+
(create the file if it does not exist).
67+
68+
MPI uses [SSH](https://en.wikipedia.org/wiki/Secure_Shell) or
69+
[RSH](https://en.wikipedia.org/wiki/Remote_Shell) to communicate with
70+
each node unless another resource manager, such as
71+
[SLURM](https://slurm.schedmd.com/overview.html), is used.
72+
If you are encountering an error "The value of the MCA parameter
73+
`plm_rsh_agent` was set to a path that could not be found",
74+
please make sure you have an SSH Client installed.
75+
6576
## Running CUDA Quantum
6677

6778
You should now be able to import CUDA Quantum and start building quantum

0 commit comments

Comments
 (0)