# Issues with pennylane lightning installation

**URL:** <https://discuss.pennylane.ai/t/issues-with-pennylane-lightning-installation/2989>\
**Category:** PennyLane Help\
**Created:** [May 30, 2023, 4:44pm UTC](https://discuss.pennylane.ai/t/issues-with-pennylane-lightning-installation/2989 "2023-05-30T16:44:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![imakash](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/imakash/32/1428_2.png) [@imakash](https://discuss.pennylane.ai/u/imakash)\
**Post date:** [May 30, 2023, 4:44pm UTC](https://discuss.pennylane.ai/t/issues-with-pennylane-lightning-installation/2989/1 "2023-05-30T16:44:30Z")

</div>

I am running the following code:

```auto
import pennylane as qml
from timeit import default_timer as timer

# To set the number of threads used when executing this script,
# export the OMP_NUM_THREADS environment variable.ls

# Choose number of qubits (wires) and circuit layers
wires = 15
layers = 3

# Set number of runs for timing averaging
num_runs = 5

# Instantiate CPU (lightning.qubit) or GPU (lightning.gpu) device
dev = qml.device('lightning.qubit', wires=wires)

# Create QNode of device and circuit
@qml.qnode(dev, diff_method="adjoint")
def circuit(parameters):
    qml.StronglyEntanglingLayers(weights=parameters, wires=range(wires))
    return [qml.expval(qml.PauliZ(i)) for i in range(wires)]

# Set trainable parameters for calculating circuit Jacobian
shape = qml.StronglyEntanglingLayers.shape(n_layers=layers, n_wires=wires)
weights = qml.numpy.random.random(size=shape)

# Run, calculate the quantum circuit Jacobian, and average the timing results
timing = []
for t in range(num_runs):
    start = timer()
    jac = qml.jacobian(circuit)(weights)
    end = timer()
    timing.append(end - start)

print("Result: ", qml.numpy.mean(timing))

```

When the device is “lightning.qubit”, I get the following warning message

```auto
/home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages/pennylane_lightning/lightning_qubit.py:893: UserWarning: Pre-compiled binaries for lightning.qubit are not available. Falling back to using the Python-based default.qubit implementation. To manually compile f
rom source, follow the instructions at https://pennylane-lightning.readthedocs.io/en/latest/installation.html.

```

And when the device is “lightning.gpu”, I get the following error message.

```auto
Traceback (most recent call last):
  File "/home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 54, in <module>
    from .lightning_gpu_qubit_ops import (
ImportError: libcudart.so.11.0: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "trial_lightninig_gpu.py", line 15, in <module>
    dev = qml.device('lightning.gpu', wires=wires)
  File "/home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages/pennylane/ __init__.py", line 316, in device
    plugin_device_class = plugin_devices[name].load()
  File "/home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages/pkg_resources/ __init__.py", line 2471, in load
    return self.resolve()
  File "/home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages/pkg_resources/ __init__.py", line 2477, in resolve
    module = __import__ (self.module_name, fromlist=[' __name__'], level=0)
  File "/home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages/pennylane_lightning_gpu/ __init__.py", line 17, in <module>
    from .lightning_gpu import LightningGPU
  File "/home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 92, in <module>
    except (ModuleNotFoundError, ImportError, ValueError, PLException) as e:
NameError: name 'PLException' is not defined

```

Output of `qml.about()`.

```auto
>>> qml.about()
Name: PennyLane
Version: 0.28.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /home/sinha/miniconda3/envs/qns/lib/python3.8/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-Lightning-GPU

Platform info: Linux-5.4.0-147-generic-x86_64-with-glibc2.17
Python version: 3.8.16
Numpy version: 1.22.3
Scipy version: 1.7.3
Installed devices:
- lightning.gpu (PennyLane-Lightning-GPU-0.30.0)
- lightning.qubit (PennyLane-Lightning-0.28.1)
- default.gaussian (PennyLane-0.28.0)
- default.mixed (PennyLane-0.28.0)
- default.qubit (PennyLane-0.28.0)
- default.qubit.autograd (PennyLane-0.28.0)
- default.qubit.jax (PennyLane-0.28.0)
- default.qubit.tf (PennyLane-0.28.0)
- default.qubit.torch (PennyLane-0.28.0)
- default.qutrit (PennyLane-0.28.0)
- null.qubit (PennyLane-0.28.0)

```

I am not sure, where exactly is the problem.

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [May 30, 2023, 8:05pm UTC](https://discuss.pennylane.ai/t/issues-with-pennylane-lightning-installation/2989/2 "2023-05-30T20:05:46Z")

</div>

Hey @imakash! It might be worth updating to the most-recent versions of everything — some of your package versions are out-of-sync (you’re pretty up-to-speed with lightning-gpu but not pl-lightning or pennylane)

> [@imakash](#):
>
> When the device is “lightning.qubit”, I get the following warning message

You can try building pl-lightning from source via `pip install pybind11 pennylane-lightning --no-binary :all:`.

> [@imakash](#):
>
> And when the device is “lightning.gpu”, I get the following error message.

This forum post might be helpful!

> [@Pennylane-Lightning GPU](https://discuss.pennylane.ai/t/pennylane-lightning-gpu/2432/9):
>
> Hi @George_LA and @mlxd and @isaacdevlugt, Even I tried the solution given by @mlxd, however, I was not able to run the script. So, instead, I did this: import torch device = torch.device("cuda:0" if (torch.cuda.is\_available()) else "cpu") I created the quantum circuit under a class. Then, I sent it to the GPU. It was able to utilize it. class QCNN(nn.Module): def CONVCircuit(phi, wires, i=0): """ quantum convolution Node """ # parameter theta = np.pi / 2 …

---

<div class="post-metadata">

**Author:** ![imakash](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/imakash/32/1428_2.png) [@imakash](https://discuss.pennylane.ai/u/imakash)\
**Post date:** [May 30, 2023, 10:34pm UTC](https://discuss.pennylane.ai/t/issues-with-pennylane-lightning-installation/2989/3 "2023-05-30T22:34:25Z")

</div>

Hello @isaacdevlugt ,

Thanks for your response. Actually this is just a dummy code to test pennylane lightning. I am actually training a Hybrid quantum Classical neural network. If I cannot make this work, can I use ‘pytorch’ interface with 'defaul.qubit" device to train on GPU a hybrid quantum-classical neural network?

If I can use ‘default.qubit’ for running the code on GPU, then what benefit does pennylane-lightning offer?

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [May 31, 2023, 2:00pm UTC](https://discuss.pennylane.ai/t/issues-with-pennylane-lightning-installation/2989/4 "2023-05-31T14:00:47Z")

</div>

> can I use ‘pytorch’ interface with 'defaul.qubit" device to train on GPU a hybrid quantum-classical neural network

Yeah that will work! For relatively small problems (\<\<20 qubits) this is a better option that using pl-lightning-gpu.

> If I can use ‘default.qubit’ for running the code on GPU, then what benefit does pennylane-lightning offer?

It’s much much faster for large simulations (\>20 qubits). But, pennylane-lightning-gpu’s claim to fame is that it combines NVIDIA’s cuQuantum SDK library with what Pennylane offers in the way of automatic differentiation, optimization, and direct support for GPU-enabled quantum gradients with adjoint differentiation. All of those points culminate in higher performance for larger circuits.
