Input type (CUDAFloatTensor) and weight type (CPUFloatTensor) should be the same

When I run my model, it returns me Input type (CUDAFloatTensor) and weight type (CPUFloatTensor) should be the same
I think that’s because I used a pretrained model and used the weights of that pretrained model maybe, because the error returns from there.
Any idea to fix it?

1 Like

In PyTorch, you need to make sure that the operands are in the same context device(both on CPU or both on GPU). Try to convey the model into GPU using:

model = model.cuda()
1 Like

and then it returns meRuntimeError: cuda runtime error (2) : out of memory at /pytorch/torch/lib/THC/generic/THCStorage.cu:58