How to fix 'Input and hidden tensors are not at the same device' in pytorch
When I want to put the model on the GPU, I get the following error:

&quot;RuntimeError: Input and hidden tensors are not at the same device, found input tensor at cuda:0 and hidden tensor at cpu&quot;

However, all of the above had been put on the GPU:
for m in model.parameters():
    print(m.device) #return cuda:0

if torch.cuda.is_available():
    model = model.cuda()
    test = test.cuda() # test is the Input


Windows 10 server
Pytorch 1.2.0 + cuda 9.2
cuda 9.2
cudnn 7.6.3 for cuda 9.2

You need to move the model, the inputs, and the targets to Cuda:
if torch.cuda.is_available():
   model.cuda()
   inputs = inputs.cuda() 
   target = target.cuda()

