Difficulties with Lightning-GPU installation

I’m not familiar with Linux but prefer to use jupyter notebook. i’d love to try the Lightning-GPU feature, which is supposedly capable of acceleration. I tried my best to deploy it on Linux, but I had problems with the installation:
The above problems make me wonder if the installation was successful.

Hello @RX1, I believe you are required to pay NVIDIA for gpu access with cuQuantum in your notebooks. Here is a post from an NVIDIA employee regarding potential pip use instead of wheels and dockers.


Hi @RX1 since NVIDIA cuQuantum is linux only, you will need to run natively on a linux system (as you are already aware). For this, you need a CUDA-backed GPU that supports CUDA compute capability 7.0 and newer.

If you have access to a Linux machine with a CUDA capable GPU, you can follow the NVIDIA CUDA install guide here. Note that lightning.gpu currently supports CUDA-11, so if you are installing a fresh environment, it will be best to install CUDA 11.8

Once you have a working CUDA installation, you can install lightning.gpu as

python -m pip install pennylane pennylane-lightning-gpu custatevec-cu11 --upgrade

You should then be able to run your jupyter notebook environment, and use lightning.gpu as a device backend.

If you do not have a working install of CUDA, or a valid GPU supporting cuQuantum, the device will fall-back to running on the CPU only and warn you of the problem with your installation. Hope this helps.

Hi @RX1 ,

You can try using Google Colab if you have a short computation to run. Google Colab offers free access to a GPU but only in limited amounts so if you want something that will run on a GPU for many hours you will need to look at buying a GPU or buying a Pro version of a service that gives you access to one.

Here are the steps you can follow for a quick test on Google Colab:

  1. Open a new notebook
  2. In the navigation bar at the top go to Runtime → Change runtime type
  3. Choose a GPU
  4. In the first cell of the notebook run !pip install pennylane custatevec-cu11 pennylane-lightning-gpu
  5. Run a simple code (such as the code below) to test that everything works
import pennylane as qml

dev = qml.device("lightning.gpu", wires=2)

def circuit():
  return qml.expval(qml.PauliZ(0))


Note that not all GPUs are compatible with lightning.qubit so if you have questions about compatibility please let us know.

Also please note that the code above will probably run faster using lightning.qubit on a CPU that using lightning.gpu on a GPU. For computations under 20 qubits I recommend using lightning.qubit.

I hope this helps!


I am also having problems with lightning.gpu

I am trying to run:

import pennylane as qml
dev = qml.device(“lightning.gpu”, wires=2)

And I am getting back:

DeviceError: Device lightning.gpu does not exist. Make sure the required plugin is installed.

But when I run:
pip install pennylane-lightning[gpu]

I get back:

Requirement already satisfied: pennylane-lightning[gpu]

Hey @morgoth , welcome to the forum!
Do you mind sharing which versions you’re using, system and GPU? That will help us figure this out for you. :slight_smile:
If you could run qml.about() and share the output, that would be great!

Thank you for answering, Ivana. This is the output:

Platform info: Linux-4.18.0-372.32.1.el8_6.x86_64-x86_64-with-glibc2.28 Python version: 3.9.7 Numpy version: 1.23.4 Scipy version: 1.9.3 Installed devices: - lightning.qubit (PennyLane-Lightning-0.32.0) - default.gaussian (PennyLane-0.32.0) - default.mixed (PennyLane-0.32.0) - default.qubit (PennyLane-0.32.0) - default.qubit.autograd (PennyLane-0.32.0) - default.qubit.jax (PennyLane-0.32.0) - default.qubit.tf (PennyLane-0.32.0) - default.qubit.torch (PennyLane-0.32.0) - default.qutrit (PennyLane-0.32.0) - null.qubit (PennyLane-0.32.0)

The GPUs available are Nvidia V100.

Hi @morgoth, this looks like an installation error. You need to install NVIDIA’s custatevec library too.

If you run the following in a new environment does it work?
pip install pennylane custatevec-cu11 pennylane-lightning-gpu

That solved it. Thanks!

I’m glad it worked @morgoth! Enjoy using PennyLane!