# Issues when using PennyLane Lightning GPU

**URL:** <https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649>\
**Category:** PennyLane Help\
**Created:** [May 23, 2024, 11:04am UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649 "2024-05-23T11:04:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zebing\_wang](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/zebing_wang/32/2594_2.png) [@zebing\_wang](https://discuss.pennylane.ai/u/zebing_wang)\
**Post date:** [May 23, 2024, 11:04am UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/1 "2024-05-23T11:04:57Z")

</div>

Hello!

I am using `lightning.gpu` to accelerate my quantum simulator, but I got an error when I ran it.

Here is the code I am testing:

```auto
dev = qml.device("lightning.gpu", wires=1)

```

The error I got is:

```auto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../anaconda/anaconda3/envs/QAG/lib/python3.10/site-packages/pennylane/ __init__.py", line 393, in device
    dev = plugin_device_class(*args, **options)
  File ".../anaconda/anaconda3/envs/QAG/lib/python3.10/site-packages/pennylane_lightning/lightning_gpu/lightning_gpu.py", line 254, in __init__
    super(). __init__ (wires, shots=shots, c_dtype=c_dtype)
  File ".../anaconda/anaconda3/envs/QAG/lib/python3.10/site-packages/pennylane_lightning/core/lightning_base.py", line 74, in __init__
    raise ImportError(
ImportError: Pre-compiled binaries for lightning.gpu are not available. To manually compile from source, follow the instructions at https://pennylane-lightning.readthedocs.io/en/latest/installation.html.

```

The version of PennyLane I am using is shown bellow:

```auto
Name: PennyLane
Version: 0.36.0
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: .../anaconda/anaconda3/envs/QAG/lib/python3.10/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane_Lightning, PennyLane_Lightning_GPU, PennyLane_Lightning_Kokkos, Quantum_Angle_Generator

Platform info: Linux-3.10.0-1160.105.1.el7.x86_64-x86_64-with-glibc2.17
Python version: 3.10.14
Numpy version: 1.26.4
Scipy version: 1.13.0
Installed devices:
- lightning.gpu (PennyLane_Lightning_GPU-0.36.0)
- default.clifford (PennyLane-0.36.0)
- default.gaussian (PennyLane-0.36.0)
- default.mixed (PennyLane-0.36.0)
- default.qubit (PennyLane-0.36.0)
- default.qubit.autograd (PennyLane-0.36.0)
- default.qubit.jax (PennyLane-0.36.0)
- default.qubit.legacy (PennyLane-0.36.0)
- default.qubit.tf (PennyLane-0.36.0)
- default.qubit.torch (PennyLane-0.36.0)
- default.qutrit (PennyLane-0.36.0)
- default.qutrit.mixed (PennyLane-0.36.0)
- null.qubit (PennyLane-0.36.0)
- lightning.kokkos (PennyLane_Lightning_Kokkos-0.36.0)
- lightning.qubit (PennyLane_Lightning-0.36.0)

```

The status of my GPU, as displayed by `nvidia-smi` , is

```auto
Thu May 23 19:04:02 2024       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla V100-SXM2... On | 00000000:15:00.0 Off | 0 |
| N/A 41C P0 43W / 300W | 0MiB / 32768MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 Tesla V100-SXM2... On | 00000000:16:00.0 Off | 0 |
| N/A 42C P0 45W / 300W | 0MiB / 32768MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+

I would greatly appreciate any guidance or insights to help address this issue. Thank you!

```

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [May 24, 2024, 3:59pm UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/2 "2024-05-24T15:59:37Z")

</div>

Hi @zebing_wang ,

Welcome to the forum!

How did you install Lightning GPU?

I recommend that you follow these steps:

1. Create a new conda environment with:  
`conda create --name name_of_your_environment python=3.10`
2. Activate the environment:  
`conda activate name_of_your_environment`
3. Install PennyLane and Lightning with  
`python -m pip install pennylane pennylane-lightning pennylane-lightning-gpu --upgrade` to ensure the version is the most recent (v0.36 as of writing).
4. `pip install custatevec-cu11` to bring in the CUDA 11 variant of the NVIDIA cuQuantum custatevec library.

Let me know if this works for you.

---

<div class="post-metadata">

**Author:** ![zebing\_wang](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/zebing_wang/32/2594_2.png) [@zebing\_wang](https://discuss.pennylane.ai/u/zebing_wang)\
**Post date:** [May 25, 2024, 1:17pm UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/4 "2024-05-25T13:17:13Z")

</div>

Hi,

Thanks for your fast reply. I have try the steps you show me to reinstall all the packages. But the error are same when I run:

```auto
dev = qml.device("lightning.gpu", wires=1)

```

Thanks!

---

<div class="post-metadata">

**Author:** ![Christophe\_Pere](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/christophe_pere/32/2417_2.png) [@Christophe\_Pere](https://discuss.pennylane.ai/u/Christophe_Pere)\
**Post date:** [May 27, 2024, 8:31pm UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/5 "2024-05-27T20:31:19Z")

</div>

HI @zebing_wang,

`lightning.gpu` uses cuQuantum and CUDA. It can be a cause if you have incompatible versions.

Best

---

<div class="post-metadata">

**Author:** ![zebing\_wang](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/zebing_wang/32/2594_2.png) [@zebing\_wang](https://discuss.pennylane.ai/u/zebing_wang)\
**Post date:** [May 28, 2024, 3:27am UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/6 "2024-05-28T03:27:36Z")

</div>

Hi,

The version of my cuQuantum is:

```auto
contourpy 1.2.1
cupy 13.1.0
cupy-cuda11x 13.1.0
cuquantum-python-cu11 24.3.0
custatevec-cu11 1.6.0.post1
cutensor-cu11 2.0.1
cutensornet-cu11 2.4.0.post1

```

The version of CUDA I am using is 11.7 I believe, I got it from `nvidia-smi`:

```auto
Tue May 28 11:22:44 2024       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.65.01 Driver Version: 515.65.01 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla V100-SXM2... On | 00000000:1F:00.0 Off | 0 |
| N/A 31C P0 43W / 300W | 0MiB / 32768MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+

```

So, I thought the version was correct, right?

Thanks!

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [May 28, 2024, 5:36pm UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/7 "2024-05-28T17:36:04Z")

</div>

Hi @zebing_wang ,

Maybe it’s an issue with the NVIDIA drivers. Does it work if you install the following in a new environment? So following steps 1, 2 and 3 from before and replacing step 4 with the line below

```auto
python -m pip install nvidia-cusparse-cu11 nvidia-cublas-cu11 nvidia-cuda-runtime-cu11 custatevec-cu11

```

---

<div class="post-metadata">

**Author:** ![zebing\_wang](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/zebing_wang/32/2594_2.png) [@zebing\_wang](https://discuss.pennylane.ai/u/zebing_wang)\
**Post date:** [May 30, 2024, 6:32am UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/8 "2024-05-30T06:32:26Z")

</div>

Hi,

I have try the steps you show me here. But the issue is still there.

Thanks!

---

<div class="post-metadata">

**Author:** ![mlxd](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/mlxd/32/526_2.png) [@mlxd](https://discuss.pennylane.ai/u/mlxd)\
**Post date:** [May 30, 2024, 3:15pm UTC](https://discuss.pennylane.ai/t/issues-when-using-pennylane-lightning-gpu/4649/9 "2024-05-30T15:15:51Z")

</div>

Hi @zebing_wang

The recent versions of LightningGPU (0.35 and 0.36) migrated to use CUDA 12 by default (release notes for 0.35 [here](https://github.com/PennyLaneAI/pennylane-lightning/releases/tag/v0.35.0)).  
If you are running a CUDA 11 system, you can try to download the CUDA 12 runtime libraries with:

```bash
python -m pip install nvidia-cusparse-cu12 nvidia-cublas-cu12 nvidia-cuda-runtime-cu12 custatevec-cu12

```

rather than the CUDA 11 versions. Assuming your driver is recent enough, the CUDA 12 libraries should work. Also, please ensure the version of LightningGpu is installed from [PennyLane-Lightning-GPU · PyPI](https://pypi.org/project/PennyLane-Lightning-GPU/#files) — if you are running on a managed HPC system, it is possible your administrators may intercept and prevent outside libraries, which may also stop you from having the pre-built wheels being installed. If so, you can manually download the wheel from that URL and install it directly with pip.

Let us know if this helps.
