An error occurred while running the GPU demo

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\ __call__  *
        res = qml.execute(
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\interfaces\ execute  *
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\interfaces\ cache_execute  *
        if expand_fn is not None:
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\tensorflow\python\autograph\operators\ if_stmt
        return _py_if_stmt(cond, body, orelse)
    D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\tensorflow\python\autograph\operators\ _py_if_stmtPreformatted text
        return body() if cond else orelse()
    C:\Users\24164\AppData\Local\Temp\ if_true
        (fn_1,) = (fn,)

    UnboundLocalError: local variable 'fn' referenced before assignment

The problem occurs when running,But I tested that the error seems to be related to @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.

There is also a discussion from nvidia forum: