An error occurred while running the GPU demo

Hi!
I tried to test the gpu training code sample under tensorflow-gpu 2.2.0+PennyLane 0.23.1, the specific URL is here:Pennylane DEMO v4, but I got some errors, can anyone give me some hints?

StagingError: in user code:

    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\qnode.py:576 __call__  *
        res = qml.execute(
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\interfaces\execution.py:337 execute  *
        qml.interfaces.cache_execute(
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\interfaces\execution.py:85 cache_execute  *
        if expand_fn is not None:
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\tensorflow\python\autograph\operators\control_flow.py:926 if_stmt
        return _py_if_stmt(cond, body, orelse)
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\tensorflow\python\autograph\operators\control_flow.py:1035 _py_if_stmtPreformatted text
        return body() if cond else orelse()
    C:\Users\24164\AppData\Local\Temp\tmplr3er8nz.py:19 if_true
        (fn_1,) = (fn,)

    UnboundLocalError: local variable 'fn' referenced before assignment

The problem occurs when running modelh.fit,But I tested that the error seems to be related to @tf.function.

@tf.function
@qml.qnode(dev, interface="tf", diff_method="backprop")
def qnode(inputs, weights):
    for i in range(blocks):
        qml.templates.AngleEmbedding(inputs, wires=range(n_qubits))
        qml.templates.StronglyEntanglingLayers(weights[i], wires=range(n_qubits)) #STRONGLY ENTANGLING LAYERS
    return [qml.expval(qml.PauliZ(i)) for i in range(n_qubits)]

What changePreformatted texts or environment are required to run the demo?

Hi @ffff12138, what version of Python are you using?

The demo only works with Python versions 3.7 and 3.8 as stated on the top of the demo. It was most likely made with PennyLane version 0.19.

Does this solve the issue you’re finding?

Hi @CatalinaAlbornoz,thank you for your reply! thank you for your reply! Sorry for replying you so late, I have been busy with work these days.

The python version is 3.7. After changing to pennylane 0.19.0, the previous error did not appear again, but a worse situation happened: once I started training with GPU A blue screen will appear with the DRIVER_IRQL_NOT_LESS_OR_EQUAL error code that occurs on nvlddmkm.sys. This problem did not occur when training other codes with tensorflow-gpu.

Has anyone experienced this?:thinking:

Hi @ffff12138,

This may mean that there is a conflict between device drivers. https://answers.microsoft.com/en-us/windows/forum/all/bsod-error-driverirqlnotlessorequal-on-windows-10/be308a16-918d-45b7-88f8-b2570a871fc1

There is also a discussion from nvidia forum: https://www.nvidia.com/en-us/geforce/forums/geforce-graphics-cards/5/311133/driverirqlnotlessorequal-nvlddmkmsys/