Expected all tensors to be on the same device, but found at least two devices,
原因是计算的过程中,两个不同类型的变量在一起进行运算,即一个变量存储在gpu中,一个变量存储在cpu中,两个变量的存储位置冲突,导致无法计算,把变量统一下就行
x = x + kp_x_ofsty = y + kp_y_ofstx = torch.reshape(x, [-1]) y = torch.reshape(y, [-1])x = x.to('cpu')y = y.to('cpu')x0 = torch.floor(x).to(torch.int32)x1 = x0 + 1y0 = torch.floor(y).to(torch.int32)y1 = y0 + 1# device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')x0 = torch.clamp(x0, zero, max_x)x1 = torch.clamp(x1, zero, max_x)y0 = torch.clamp(y0, zero, max_y)y1 = torch.clamp(y1, zero, max_y)