Cirq simulator device error

Trying to runt the qGANs tutorial (https://pennylane.ai/qml/demos/tutorial_QGAN.html) on jupyter notebooks but I keep getting ‘DeviceError: Device does not exist. Make sure the required plugin is installed.’ when the cirq.simulator is called for

Hi @Zohim_Chandani. Welcome to the forum and thanks for using PennyLane ! Have you installed the PennyLane-Cirq plugin by using the following command?

$ pip install pennylane-cirq

Please take a look here and let us know if the error is still present.

Successfully installed pennylane-cirq-0.9.0

but when I run: dev = qml.device(‘cirq.simulator’, wires=3)
I get DeviceError: Device does not exist. Make sure the required plugin is installed.

Thanks @Zohim_Chandani. Could you please tell me which versions of Python, PennyLane, Cirq, and TensorFlow you have installed and which code editor you use?

python 3.7.4
tensorflow 2.1.0
pennylane 0.10.0
pennylane-cirq 0.9.0

Could you please also run this:

print(cirq.__version__)

I get NameError: name ‘cirq’ is not defined

and when i run dev = qml.device(‘cirq.simulator’, wires=3)
I get
ContextualVersionConflict: (protobuf 3.8.0 (c:\programdata\anaconda3\lib\site-packages), Requirement.parse(‘protobuf>=3.12.0’), {‘google-api-core’})

Could you please follow these steps and let me know the result?

pip uninstall google-api-core
pip install google-api-core==1.20.0
pip uninstall cirq
pip install cirq

Also, did you observe any warning message when installing cirq and cirq plugin?

No issues when installing cirq and cirq plugin but uninstalling google api core and installing it again seems to have fixed the issue. Thankyou.

Hello.

I am having similar problems while trying to run https://pennylane.ai/qml/demos/tutorial_quantum_transfer_learning.html .

I get the following response:

"OSError Traceback (most recent call last)
in
----> 1 import torch
2 import torch.nn as nn
3 import torch.optim as optim
4 from torch.optim import lr_scheduler
5 import torchvision

C:\ProgramData\Anaconda3\lib\site-packages\torch_init_.py in
79 dlls = glob.glob(os.path.join(th_dll_path, ‘*.dll’))
80 for dll in dlls:
—> 81 ctypes.CDLL(dll)
82
83

C:\ProgramData\Anaconda3\lib\ctypes_init_.py in init(self, name, mode, handle, use_errno, use_last_error)
362
363 if handle is None:
–> 364 self._handle = _dlopen(self._name, mode)
365 else:
366 self._handle = handle

OSError: [WinError 182] The operating system cannot run %1"

I have installed all packages before through Anaconda.

Hi @_risto,

It appears there is something wrong with your pytorch installation.

Doing a quick search of the error message reveals the following similar github issue for PyTorch (with suggested solutions). I’d recommend considering some of the suggestions from there.

Hi.

I get the same error, despite following the code and https://pennylane-sf.readthedocs.io/en/latest/devices/fock.html

Hi @_risto,

Do you mean this error?: ‘DeviceError: Device does not exist. Make sure the required plugin is installed.’

If so, could you please post the output of qml.about() (run in the same session where you observe the error)?

If you are referring to the you mentioned previously on the line import torch, this appears to be a pytorch issue, so I would encourage you to check the pytorch github to see how to resolve the issue :slightly_smiling_face:

From https://pennylane.ai/qml/demos/quantum_neural_net.html when I run:

dev = qml.device(“strawberryfields.fock”, wires=1, cutoff_dim=10)
import pennylane as qml

dev = qml.device(‘strawberryfields.fock’, wires=2, cutoff_dim=10)

I get:DeviceError Traceback (most recent call last)
in
----> 1 dev = qml.device(“strawberryfields.fock”, wires=1, cutoff_dim=10)
2 import pennylane as qml
3
4 dev = qml.device(‘strawberryfields.fock’, wires=2, cutoff_dim=10)

~\anaconda3\lib\site-packages\pennylane_init_.py in device(name, *args, **kwargs)
253 return plugin_device_class(*args, **options)
254
–> 255 raise DeviceError(“Device does not exist. Make sure the required plugin is installed.”)
256
257

DeviceError: Device does not exist. Make sure the required plugin is installed.

When running: qml.about()
I get:
NameError Traceback (most recent call last)
in
----> 1 qml.about()

NameError: name ‘qml’ is not defined

Hi @_risto ,

Did you run

import pennylane as qml

before

qml.about()

The output of qml.about() will tell us which plugins are successfully installed.

Hi @christina

Yes. It is the first line in the tutorial.

Hi @_risto,

Indeed, it is in the tutorial, but from your traceback, it appears you actually ran that command as “line 1” of a program (so potentially you ran it separately from the tutorial).
If you do the sequence

import pennylane as qml
qml.about() 

you should be successful

Hi @nathan


Hi @_risto, as you can see from the output, the strawberryfields.fock plugin has not been installed into the same environment where you are running this notebook (it would appear under Installed devices).

You’ll have to enter pip install pennylane-sf in the terminal (making sure you are in the correct conda or virtual environment). Or you can install directly in jupyer notebook by executing a cell with !pip install pennylane-sf