问题:RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat2 in method wrapper_mm)
原因
参与运算的两个或多个变量,有的在CPU上,有的在GPU上
解决方案
若在gpu上运行,则把所有变量都放在gpu上
如:
device=torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model=GCN_Net(dataset.num_node_features,16,dataset.num_classes).to(device)
data=dataset[0].to(device)