Error occurs for "Device does not exist"

Hi

I just run the codes below but it appears the messages that fail to execute on Spider as follows

"File “D:\Anaconda\lib\site-packages\pennylane_init_.py”, line 332, in device
raise DeviceError(“Device does not exist. Make sure the required plugin is installed.”)

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

import pennylane as qml
from pennylane import qaoa
from pennylane import numpy as np
from matplotlib import pyplot as plt
import networkx as nx

edges = [(0, 1), (1, 2), (2, 0), (2, 3)]
graph = nx.Graph(edges)

nx.draw(graph, with_labels=True)

plt.show()

cost_h, mixer_h = qaoa.min_vertex_cover(graph, constrained=False)

print(“Cost Hamiltonian”, cost_h)
print(“Mixer Hamiltonian”, mixer_h)

def qaoa_layer(gamma, alpha):
qaoa.cost_layer(gamma, cost_h)
qaoa.mixer_layer(alpha, mixer_h)

wires = range(4)
depth = 2

def circuit(params, **kwargs):
for w in wires:
qml.Hadamard(wires=w)
qml.layer(qaoa_layer, depth, params[0], params[1])

dev = qml.device(“qulacs.simulator”, wires=wires)

@qml.qnode(dev)
def cost_function(params):
circuit(params)
return qml.expval(cost_h)

I checked with qml.about()

WARNING: Ignoring invalid distribution -5py (d:\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -iskit-terra (d:\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -iskit-aer (d:\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\anaconda\lib\site-packages)
WARNING: Ignoring invalid distribution - (d:\anaconda\lib\site-packages)
Name: PennyLane
Version: 0.26.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: d:\anaconda\lib\site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, retworkx, scipy, semantic-version, toml
Required-by: PennyLane-Cirq, PennyLane-Lightning, PennyLane-qiskit, PennyLane-SF

Platform info: Windows-10-10.0.19041-SP0
Python version: 3.8.8
Numpy version: 1.19.5
Scipy version: 1.8.0
Installed devices:

  • default.gaussian (PennyLane-0.26.0)
  • default.mixed (PennyLane-0.26.0)
  • default.qubit (PennyLane-0.26.0)
  • default.qubit.autograd (PennyLane-0.26.0)
  • default.qubit.jax (PennyLane-0.26.0)
  • default.qubit.tf (PennyLane-0.26.0)
  • default.qubit.torch (PennyLane-0.26.0)
  • default.qutrit (PennyLane-0.26.0)
  • strawberryfields.fock (PennyLane-SF-0.20.1)
  • strawberryfields.gaussian (PennyLane-SF-0.20.1)
  • strawberryfields.gbs (PennyLane-SF-0.20.1)
  • strawberryfields.remote (PennyLane-SF-0.20.1)
  • strawberryfields.tf (PennyLane-SF-0.20.1)
  • qiskit.aer (PennyLane-qiskit-0.18.0)
  • qiskit.basicaer (PennyLane-qiskit-0.18.0)
  • qiskit.ibmq (PennyLane-qiskit-0.18.0)
  • lightning.qubit (PennyLane-Lightning-0.26.1)
  • cirq.mixedsimulator (PennyLane-Cirq-0.17.1)
  • cirq.pasqal (PennyLane-Cirq-0.17.1)
  • cirq.qsim (PennyLane-Cirq-0.17.1)
  • cirq.qsimh (PennyLane-Cirq-0.17.1)
  • cirq.simulator (PennyLane-Cirq-0.17.1)

Hi @SuFong_Chien,

You need to install the plugin for qulacs. You can do:

python -m pip install pennylane-qulacs["cpu"]

Or change “cpu” to “gpu” if you have access to GPU.

Please let me know if this solves your problem!

TQ. No longer see the error message.

Awesome! :raised_hands: