Skip to content
Advertisement

RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same – PyTorch

I’m trying to push both my mode and data, images and labels, to run on the GPU by doing:

JavaScript

Followed by:

JavaScript

I’m explicitly pushing my model and data to device however I am met by the error:

JavaScript

I feel like I’m doing the right thing by pushing both model and data to GPU but I can’t figure out why it’s not working. Does somebody know what’s going wrong? Thank you in advance.

Advertisement

Answer

Your weights are saved on your gpu but your input is on your cpu. You can change that by: images.cuda()

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement