For my final part of the master thesis I’m running a algorithm on a large dataset. I’m very new to Python and PyTorch. But was recommended that the great forum here could give some guidance. On CPU the code runs without any problems.
if torch.cuda.is_available():
print(‘Training on GPU:’)
print(torch.cuda.get_device_name(0))
else:
print(‘Training on CPU!!!’)
device = torch.device(‘cuda:0’ if torch.cuda.is_available() else ‘cpu’)
Returns Training on GPU and then GeForce GTX 1650 Ti. cuda:0 is also positive.
I’m trying to use Torch 1.7.1+cu110 with Python 3.9.
The moment I try to add: model.to(device) it returns:
RuntimeError: Tensor for ‘out’ is on CPU, Tensor for argument #1 ‘self’ is on CPU, but expected them to be on GPU (while checking arguments for addmm)
The moment I try to add: torch.set_default_tensor_type(‘torch.cuda.FloatTensor’) it returns:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
Help??? Anybody?