HOWTO: Set up nVidia’s cuQuantum Python
These instructions will get you started in using JupyterHub with cuQuantum’s Python support. You may want to start with the samples provided with cuQuantum to become familiar with the APIs. Full documentation is available here.Start JupyterHub
Start a JupyterHub instance with at least the following settings:- Partition: GPU Preempt
- Number of CPUs: 4
- Memory Alloction: 8192
- Number of GPUS: 1
Enable conda-forge
Once your instance has started, start a Terminal (File→New→Terminal, or via the Launcher), and run this command to ensure the conda-forge channel is configured:conda config --add channels conda-forge
If you already had it configured, you’ll get a notification that it was moved to the top of the list. Note if you want to use the samples that use pytorch, then you should also add the pytorch channel.
Create a new Conda Envirornment
Next, head to Settings→Conda Packages Manager. From there, first press the refresh button in the upper right to ensure it fetches the package list from the new channels. Then, pres the “+” button under Conda Environemnts to create a new environment for cuQuantum. You may call it whatever you wish. Once this has been created, it will appear in the list. Select it if is isn’t selected automatically. Search the package list for cuquantum, and then tick the boxes next to qsimcirq (select a cuda version for GPU support), cuquantum and cuquantum-python, and press the Shopping Cart icon in the upper right to add the packages. This operation may take a while to complete.Begin!
Once the environment is complete, create a new notebook (File→New→Notebook) and select the kernel you just created, which should be listed something like Python (.conda-quantum). Now you should be able to use any of the samples linked above.Now you should be able to use these in your notebook (after restarting the kernel):
import qsim, qimscirq
import cirq
print(qsimcirq.qsim_gpu) # Verify GPU support was enabled