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

Hi,
i was trying to execute the in code in github
https://github.com/sophchoe/Binary_Classification_Pennylane_Keras/blob/main/fraud_detection_Pennylane_Keras.ipynb

but i was getting error in Quantum Circuit part of this code

# select a device 

dev = qml.device("strawberryfields.fock", wires=num_modes, cutoff_dim=num_basis)

here the error comes like

---------------------------------------------------------------------------
DeviceError                               Traceback (most recent call last)
<ipython-input-19-4b62c45398d1> in <module>()
      3 
      4 # select a devide
----> 5 dev = qml.device("strawberryfields.fock", wires=num_modes, cutoff_dim=num_basis)
      6 
      7 @qml.qnode(dev, interface="tf")

/usr/local/lib/python3.7/dist-packages/pennylane/__init__.py in device(name, *args, **kwargs)
    303         return dev
    304 
--> 305     raise DeviceError("Device does not exist. Make sure the required plugin is installed.")
    306 
    307 

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

pls give me your inputs on this

i will also attach my google colab link

https://colab.research.google.com/drive/1JPqLRMYFX54IIpEt2aI67-E4SyP1xxRv?usp=sharing

thanks!

looking forward to your support

Hi @JEEVARATHINAM,

You need to have installed the PennyLane-SF plugin.

You can install it using pip install PennyLane-SF.

I hope this helps!

1 Like

Now im getting error while runing the model training part

while executing the below code

opt = keras.optimizers.Adam(learning_rate=0.01)

model.compile(opt, loss = 'MSE', metrics = ['accuracy'])

history = model.fit(X_train, 

                    y_train,

                    epochs = 40,

                    batch_size = 190,

                    shuffle = True,

                    validation_data=(X_test, y_test))


im getting error like:



Epoch 1/40
---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-11-beac6fcaf23e> in <module>()
      8                     batch_size = 190,
      9                     shuffle = True,
---> 10                     validation_data=(X_test, y_test))


1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
   7184 def raise_from_not_ok_status(e, name):
   7185   e.message += (" name: " + name if name is not None else "")
-> 7186   raise core._status_to_exception(e) from None  # pylint: disable=protected-access
   7187 
   7188 

InvalidArgumentError: cannot compute Mul as input #1(zero-based) was expected to be a float tensor but is a double tensor [Op:Mul]

looking forward to your support

For reference look the same colab which i had mentioned in the first post of this topic

Thanks!

Try to run this code in your lap…using the GitHub…

Hi @JEEVARATHINAM from what I see in the error, your data is a different type from what the code says it is. Notice how in the code you’re specifying that your data is of type “float32” but apparently it’s not. I’d try converting your data or changing the type specified in the code.

Also, try to run the demo exactly as it is with the dataset provided. If you run into issues in that case then the problem might be different.

I hope this helps!

hi,
Just now I again tried running the code.

i didnt do anychange with data i m just executing with same csv file which is from zip folder.

Still I m getting errors

so pls help me with that

here in am attaching the csv file link

you can download and execute the code in your lap.

looking forward to your suggestion

Pls refer to the same notebook in the first post of this topic.
Feel free to edit

Hi @JEEVARATHINAM, I’m able to reproduce your error. It’s strange because this demo run perfectly when it was submitted. You should create a new virtual environment with the same versions as specified on the top of the notebook. This should make the demo work again.

Hi @JEEVARATHINAM; if you install an external plugin device on Colab, you will need to restart the runtime ( RuntimeRestart Runtime ) before the newly installed PennyLane devices are available.

Let me know if that helps!

Hi,
Thank you for your help.

Many times I had restarted the runtime both in colab as well as in databricks. But the code is not working

It will be very helpful if we connect through Google meet. So that we can rectify this error in my environment.

I m ready to share the invite as per your schedule.

Looking forward to your support.

Kindly help me. Forsure I will help many others…who are facing this same issue

Thanks!

Hi @JEEVARATHINAM, unfortunately we cannot connect through a google meet. I will keep looking onto how this problem can be fixed and if you want we can meet at the PennyLane community calls which we hold on Thursdays at 11am ET on the Unitary Fund Discord (in the community-call voice channel).

Hi,
Thank you so much for your guidance.

Atlast I have run my model in databricks community edition.

But I am struggling to save the model.

It shows me error while saving the model

Can you guide me how to save this model in a proper way.

Thanks!

Hi @JEEVARATHINAM, can you please share your code and the error you’re getting when saving the model? If it’s a databricks issue then it’s best to ask them directly. If it’s a PennyLane issue then we can help.

hello! have you solved the problem yet?
i had the same problem

what should I do?
thanks very much!

Hi @sy1234,

The current demo has a lot of dtype assignments to float32 and int32. Your computer probably requires you to change this to float64 and int64.

Please let me know if these changes solve your problem!