Hi @RX1 ,
You can try using Google Colab if you have a short computation to run. Google Colab offers free access to a GPU but only in limited amounts so if you want something that will run on a GPU for many hours you will need to look at buying a GPU or buying a Pro version of a service that gives you access to one.
Here are the steps you can follow for a quick test on Google Colab:
- Open a new notebook
- In the navigation bar at the top go to Runtime → Change runtime type
- Choose a GPU
- In the first cell of the notebook run
!pip install pennylane custatevec-cu11 pennylane-lightning-gpu
- Run a simple code (such as the code below) to test that everything works
import pennylane as qml
dev = qml.device("lightning.gpu", wires=2)
@qml.qnode(dev)
def circuit():
qml.Hadamard(wires=0)
qml.CNOT(wires=[0,1])
return qml.expval(qml.PauliZ(0))
circuit()
Note that not all GPUs are compatible with lightning.qubit so if you have questions about compatibility please let us know.
Also please note that the code above will probably run faster using lightning.qubit
on a CPU that using lightning.gpu
on a GPU. For computations under 20 qubits I recommend using lightning.qubit
.
I hope this helps!