# GPU utilization is low

**URL:** <https://discuss.pennylane.ai/t/gpu-utilization-is-low/7897>\
**Category:** PennyLane Help\
**Created:** [January 25, 2025, 7:09pm UTC](https://discuss.pennylane.ai/t/gpu-utilization-is-low/7897 "2025-01-25T19:09:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Afrah](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Afrah](https://discuss.pennylane.ai/u/Afrah)\
**Post date:** [January 25, 2025, 7:09pm UTC](https://discuss.pennylane.ai/t/gpu-utilization-is-low/7897/1 "2025-01-25T19:09:46Z")

</div>

I am working on hybrid neural networks. The output of Pennylane. about() is as follows:

```auto
Name: PennyLane
Version: 0.29.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/anaconda3/envs/pennylane0.29-sf/lib/python3.10/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-SF

Platform info: Linux-5.4.0-200-generic-x86_64-with-glibc2.31
Python version: 3.10.16
Numpy version: 1.23.5
Scipy version: 1.9.3
Installed devices:
- default.gaussian (PennyLane-0.29.0)
- default.mixed (PennyLane-0.29.0)
- default.qubit (PennyLane-0.29.0)
- default.qubit.autograd (PennyLane-0.29.0)
- default.qubit.jax (PennyLane-0.29.0)
- default.qubit.tf (PennyLane-0.29.0)
- default.qubit.torch (PennyLane-0.29.0)
- default.qutrit (PennyLane-0.29.0)
- null.qubit (PennyLane-0.29.0)
- lightning.qubit (PennyLane-Lightning-0.29.0)
- strawberryfields.fock (PennyLane-SF-0.29.1)
- strawberryfields.gaussian (PennyLane-SF-0.29.1)
- strawberryfields.gbs (PennyLane-SF-0.29.1)
- strawberryfields.remote (PennyLane-SF-0.29.1)
- strawberryfields.tf (PennyLane-SF-0.29.1)

```

However, I saw that GPU utilization is low, and the code is faster on the CPU than on the GPU . Here is a scene shot of the first few iterations with some settings:

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/2/2a7794388fde8ec978f7bd10e1b9785de14d80e1.jpeg)

and the same code running on GPU:

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/8/8285d781da79acd6df1225bf6b3b19b0a3e4e64f.png)

---

<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:** [January 28, 2025, 1:01am UTC](https://discuss.pennylane.ai/t/gpu-utilization-is-low/7897/2 "2025-01-28T01:01:41Z")

</div>

Hi @Afrah ,

I noticed a few things.

You’re using 4 qubits, so in this regime using CPU will always be faster than using GPUs. There are computation overheads when using GPUs so for small circuits it’s not worth it. Check the [Performance section of the PennyLane website](https://pennylane.ai/performance#just-in-time-compilation-with-catalyst), where we describe where one simulator or the other works best.

On the other hand, I didn’t see `lightning.gpu` or `lightning.kokkos` as installed devices. Your quantum circuit may not be running on GPUs after all. Find how to install them in the [Install section](https://pennylane.ai/install#high-performance-computing-and-gpus) of the PennyLane website. Note that for `lightning.gpu` you will need an NVIDIA GPU with Volta or Ampere architecture.

Finally, you’re using a very old version of PennyLane. The current supported version is v0.40, while you’re using v0.29. Use `python -m pip install pennylane --upgrade` to upgrade to the latest version.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![Afrah](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@Afrah](https://discuss.pennylane.ai/u/Afrah)\
**Post date:** [January 29, 2025, 11:06am UTC](https://discuss.pennylane.ai/t/gpu-utilization-is-low/7897/3 "2025-01-29T11:06:38Z")

</div>

Thanks for your insights! I wanted to clarify a couple of things:

1. The code is slow even with just **2 qumodes and a cutoff\_dim of 3** because I am using a **batch size of 64** and running the circuit for each batch sample. Using a large number of qumodes is inherently prohibitive with CV quantum simulations.
2. I am using an **older version of PennyLane** because I am implementing a **continuous variable quantum neural network (CVQNN)** based on the approach described in [this reference](https://journals.aps.org/prresearch/pdf/10.1103/PhysRevResearch.1.033063). After testing different configurations, the combination of libraries shown in `pennylane.about()` is the only one that works reliably for my implementation.

I’d really appreciate it if you could provide an example or any guidance on how to implement a CVQNN using the newer version of PennyLane.

---

<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:** [January 29, 2025, 10:37pm UTC](https://discuss.pennylane.ai/t/gpu-utilization-is-low/7897/4 "2025-01-29T22:37:31Z")

</div>

Hi @Afrah ,

I didn’t realize you were using the PennyLane-SF plugin. Unfortunately the plugin is not supported in newer versions of PennyLane so you do need to use v0.29 of PennyLane.

For working with CV quantum computing I’d actually recommend [MrMustard](https://mrmustard.readthedocs.io/en/latest/) instead of Strawberry Fields. Unfortunately it’s not compatible with PennyLane but it does allow for optimization, as you can see at the end of the [API reference](https://mrmustard.readthedocs.io/en/latest/introduction/basic_reference.html).

I’m not sure if this is what you were looking for, but it might help you if you’re interested specifically in CV.
