Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document setup for GPU on GCP #416

Closed
95-martin-orion opened this issue Aug 17, 2021 · 6 comments
Closed

Document setup for GPU on GCP #416

95-martin-orion opened this issue Aug 17, 2021 · 6 comments
Assignees

Comments

@95-martin-orion
Copy link
Collaborator

The existing GCP documentation details how to set up a GCP VM to run Cirq circuits with qsimcirq, but only covers CPU-based execution. Now that GPU support is available at the qsimcirq level, we should also document how to use it on GCP.

Key details to cover:

  • GPUs must be attached to the GCP VM during creation (docs)
  • GPU drivers must be installed (docs)
  • The CUDA toolkit must be installed and added to the PATH
    • Installation: sudo apt install -y nvidia-cuda-toolkit
    • Add to PATH: export PATH=/usr/local/cuda-11.4/bin${PATH:+:${PATH}}
    • Note that adding to PATH must be done in each console session, or in the .bashrc file.
  • qsimcirq must be compiled on a device with the CUDA toolkit (the PyPI package only has CPU support)

CC @jrossthomson

@vcatherine
Copy link

CC @cognigami

@peterse
Copy link

peterse commented Sep 15, 2021

It would also be helpful to have a diagnostic that a user can run to determine whether GPU simulation is actually enabled for qsimcirq (some script that fails with certainty if run on a device without GPUs or appropriate drivers).

@95-martin-orion
Copy link
Collaborator Author

It would also be helpful to have a diagnostic that a user can run to determine whether GPU simulation is actually enabled for qsimcirq (some script that fails with certainty if run on a device without GPUs or appropriate drivers).

@peterse you can run pytest qsimcirq_tests/qsimcirq_test.py -k gpu_sim to check this. test_cirq_qsim_gpu_simulate will pass if the GPU is available; otherwise, it will be skipped.

@95-martin-orion
Copy link
Collaborator Author

Copied from the external thread:

If you're using qsimcirq v0.10.2, it's not using GPU - we haven't cut a release with the support yet.

Once qsimcirq GPU support is released (or if you're using the prerelease version of qsim), you can run

python3 -c 'import qsimcirq; print(qsimcirq.qsim_gpu)'

from the command line to determine whether qsim is using GPU. If GPU is not in use this will print None, and if GPU is in use it will print the module descriptor for the qsim-GPU pybind module. This descriptor is not None, and looks something like <module 'qsimcirq.qsim_avx2' from '{...}/qsim/qsimcirq/qsim_gpu{...}'>.

@95-martin-orion
Copy link
Collaborator Author

One final note: because GPU support requires local compilation on a machine with GPU support, a fresh release of qsimcirq isn't particularly helpful here, since anyone using GPU is presumably already cloning from master.

Sorry for the runaround here!

@95-martin-orion 95-martin-orion self-assigned this Sep 20, 2021
@95-martin-orion
Copy link
Collaborator Author

This has been resolved by #435. Further improvements to the GPU usage process are currently tracked by #430 and #450.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants