RuntimeError: CUDA error: device-side assert triggered CUDA kernel errors might be asynchronously

created at 01-26-2022 views: 11

error

Traceback (most recent call last):
  File "E:/Program Files/PyCharm 2019.2/PyG/test.py", line 70, in <module>
    loss.backward()  # 反向传播计算梯度
  File "F:\Anaconda3\lib\site-packages\torch\_tensor.py", line 307, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph, inputs=inputs)
  File "F:\Anaconda3\lib\site-packages\torch\autograd\__init__.py", line 156, in backward
    allow_unreachable=True, accumulate_grad=True)  # allow_unreachable flag
RuntimeError: CUDA error: device-side assert triggered
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

reason

When building a GCN model:

self.conv1 = GCNConv(features, 32)
self.conv2 = GCNConv(32, classes)

classes is inconsistent with the number of classes in the original data.

solution

self.conv2 = GCNConv(32, dataset.num_classes)
created at:01-26-2022
edited at: 01-26-2022: