遇到上述错误可能是由于没有将所有变量搬到GPU上去,你可以尝试这样做,并且一定要注意顺序
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
g, features, labels, mask = load_cora_data()
g = g.to(device)
#注意这里顺序不能乱,g进行转换后再赋给GAT
net = GAT(g, in_dim=features.size()[1], hidden_dim=8, out_dim=2, num_heads=8)
net = net.to(device)
#下面这些变量同样需要进行转换
features = features.to(device)
labels = labels.to(device)
mask = mask.to(device)