Problem when installing "lightning.gpu"

Hi, I have a question about the installation of “lightning.gpu”, here is my error why trying to use “lightning.gpu”

import pennylane as qml
dev = qml.device('lightning.gpu', wires=4)

The error message is shown below:

/work/acslab/users/anaconda3/envs/torchcuda/lib/python3.11/site-packages/pennylane_lightning/lightning_gpu/lightning_gpu.py:76: UserWarning: libcublas.so.11: cannot open shared object file: No such file or directory
  warn(str(e), UserWarning)
/work/acslab/users/baobach/anaconda3/envs/torchcuda/lib/python3.11/site-packages/pennylane_lightning/lightning_gpu/lightning_gpu.py:958: UserWarning: 
                "Pre-compiled binaries for lightning.gpu are not available. Falling back to "
                "using the Python-based default.qubit implementation. To manually compile from "
                "source, follow the instructions at "
                "https://pennylane-lightning.readthedocs.io/en/latest/installation.html.",
            
  warn(

I have tried “–force-reinstall --no-cache-dir” for penny lane, penny lane-lightning[gpu] and cuquantum-python but it is not working.
Here is my cuda version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Mon_Apr__3_17:16:06_PDT_2023
Cuda compilation tools, release 12.1, V12.1.105
Build cuda_12.1.r12.1/compiler.32688072_0

and the version of my package:

Name: PennyLane
Version: 0.33.1
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/PennyLaneAI/pennylane
Author: 
Author-email: 
License: Apache License 2.0
Location: /work/acslab/users/baobach/anaconda3/envs/torchcuda/lib/python3.11/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

Platform info:           Linux-3.10.0-957.27.2.el7.x86_64-x86_64-with-glibc2.17
Python version:          3.11.5
Numpy version:           1.26.2
Scipy version:           1.11.4
Installed devices:
- default.gaussian (PennyLane-0.33.1)
- default.mixed (PennyLane-0.33.1)
- default.qubit (PennyLane-0.33.1)
- default.qubit.autograd (PennyLane-0.33.1)
- default.qubit.jax (PennyLane-0.33.1)
- default.qubit.legacy (PennyLane-0.33.1)
- default.qubit.tf (PennyLane-0.33.1)
- default.qubit.torch (PennyLane-0.33.1)
- default.qutrit (PennyLane-0.33.1)
- null.qubit (PennyLane-0.33.1)
- lightning.qubit (PennyLane-Lightning-0.33.1)
- lightning.gpu (PennyLane-Lightning-GPU-0.33.1)

Hi @Bach_Bao, welcome to the Forum!

I think you might be missing custatevec, which is an NVIDIA library, and the CUDA version is too high.
I would recommend creating a new virtual environment and running the following:

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

Also, note that lightning.gpu requires a CUDA compute capability of SM7.0 or newer (Volta era and newer), so make sure that your GPU is compatible. You can find more details in the answer by mlxd here.

Let me know if this solves your issue!

By the way, we have a very small survey for PennyLane v0.33, and it would be awesome if you’d give us some feedback and tell us about your needs. Thank you! :grin:

2 Likes