Pennylane 0.19 and lightning qbit

Hi @_risto, yes you should be able to install it on Windows 11. Edit: Since cuQuantum only works on Linux, lightning.gpu can only be used on Linux.

You must have Python 3.7 or above and you also need to have installed the NVIDIA cuQuantum SDK.

You can install the PennyLane-Lightning-GPU plugin by using pip: pip install pennylane-lightning[gpu]

You can see more installation options here, although pip should be sufficient.

Note that you do need to have access to an NVIDIA GPU in order to be able to use this device.

Please let me know if any of this helps resolve your problem or if it still persists!

How can PennyLane-Lightning-GPU be supported by windows, if there is no windows support for NVIDIA cuQuantum SDK?

Hi @_risto, you’re totally right.

pennylane-lightning[gpu] does in fact only work together with cuQuantum, which is in fact only supported on Linux.

Sorry for the inconvenience here!

Hi @_risto

Yes, as there is no Windows support for cuQuantum, lightning.gpu will not natively work on a Windows machine directly.

As a potential workaround, we can offer some suggestions, though we are not able to provide support for this type of environment, so how effective this will be may vary:


  • Using WSL, a Windows user may access a Linux runtime on a Windows machine.
  • NVIDIA and Windows provide some supports for a CUDA-capable WSL environment (see here and here for setup and configuration).
  • The above may allow your Windows machine to have access to a Linux runtime with CUDA, which may potentially allow installation and usage of a capable NVIDIA GPU with the lightning.gpu backend. You can create an environment and attempt to pip install as before, but within WSL.

We have no guarantees this will work, as lightning.gpu is strictly developed for Linux and HPC capable CUDA GPUs, but it may allow you to get the device working, provided your GPU is supported by the cuQuantum library. Feel free to let us know if the above works for you.

Hi @CatalinaAlbornoz

While running:
dev = qml.device(“lightning.gpu”, wires=22)
I get:
WARNING: INSUFFICIENT SUPPORT DETECTED FOR GPU DEVICE WITH lightning.gpu
!!! DEFAULTING TO CPU DEVICE lightning.qubit

Hi @_risto,

Thank you for posting this error here.

Could you please post the output of qml.about()?

Hi @_risto this error is reported normally if your CUDA installation is not correctly configured, or your device is not supported by the cuQuantum library. I would suggest first trying to install cuquantum explicitly with pip install cuquantum, and retrying the above through WSL. If there was any additional errors or warning reported please feel free to let us know.

Also, it is worth noting that cuQuantum expects a CUDA device with Volta or Ampere architectures (see https://docs.nvidia.com/cuda/cuquantum/custatevec/release_notes.html#custatevec-v0-0-1) and so may not run on consumer devices if that is the target.

Since this is targeting an unsupported use-case of CUDA through WSL, we cannot guarantee this will work as expected.

Hi @CatalinaAlbornoz

Thank you for your answer. What would be appropriate configuration instead of WSL? Dual-booting or VM?

Best regards

Hi @_risto, I don’t think you need either.

What I can see in the NVIDIA docs is that WSL is supposed to help you avoid both options.

Any thoughts on this @mlxd?

Hi @_risto, as @CatalinaAlbornoz says, assuming WSL works you should not need to explore using either of the other options. However, if it does not work, and assuming you have a GPU capable of working with cuQuantum (of Volta generation or newer), then the other option is a Linux installation (dual-booting as you have stated).

While we cannot recommend going down this route, as it often requires a lot of steps to avoid any damage to your operating system (see here for more details), running Linux natively is the configuration we expect for using the GPU device.

I should add, that the GPU device was written mostly for high-performance computing (HPC) systems, as well as cloud systems, rather than consumer grade GPU hardware, so if it is an option to instead make use of a HPC system with GPUs, or to avail of a cloud GPU instance, that would be the better (and preferred) option to running it locally.

Hope this helps.

Hi @CatalinaAlbornoz
Sorry for the late reply:
Name: PennyLane
Version: 0.24.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: GitHub - PennyLaneAI/pennylane: PennyLane is a cross-platform Python library for differentiable programming of quantum computers. Train a quantum computer the same way as a neural network.
Author: None
Author-email: None
License: Apache License 2.0
Location: /home/risto/.local/lib/python3.8/site-packages
Requires: scipy, autoray, appdirs, retworkx, autograd, pennylane-lightning, toml, numpy, networkx, semantic-version, cachetools
Required-by: PennyLane-Lightning, PennyLane-Lightning-GPU

Platform info: Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.29
Python version: 3.8.10
Numpy version: 1.23.1
Scipy version: 1.8.1
Installed devices:

  • default.gaussian (PennyLane-0.24.0)
  • default.mixed (PennyLane-0.24.0)
  • default.qubit (PennyLane-0.24.0)
  • default.qubit.autograd (PennyLane-0.24.0)
  • default.qubit.jax (PennyLane-0.24.0)
  • default.qubit.tf (PennyLane-0.24.0)
  • default.qubit.torch (PennyLane-0.24.0)
  • lightning.qubit (PennyLane-Lightning-0.24.0)
  • lightning.gpu (PennyLane-Lightning-GPU-0.24.1)

Hi @_risto, thank you for sharing these details.

As @mlxd mentioned, it’s possible that you’re working with an unsupported GPU device.

You will need a GPU with Volta or Ampere architectures (see https://docs.nvidia.com/cuda/cuquantum/custatevec/release_notes.html#custatevec-v0-0-1 ).

One option to access supported machines is through Amazon Braket. You can learn more on the PennyLane blog or the Amazon Braket blog.

Please let us know if this helps.

Hi @CatalinaAlbornoz

I have RTX3060 laptop version, which is supported. Any other possible cause perhaps for the error?

Hi @_risto,

There are 2 additional suggestions:

1 - Update the LD_LIBRARY_PATH environment variable as follows before running test.py:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/complete/path/to/cuquantum-sdk/lib/

Without updating LD_LIBRARY_PATH , the lightning.gpu cannot figure out where the library exists and it switches to lightning.qubit instead :slightly_smiling_face:

2 - Double-check the commands used to build lightning.gpu. For example, building the library using python setup.py should be like the following:

python setup.py build_ext --cuquantum=/path/to/cuquantum-sdk 
python setup.py install

Please let me know if this solves your problem!