It seems like the error is a bit different from you have in the topic title. In your code you explicitly put the model on the cuda device. But I never see you put your tensor on the same device as well. So, something like tensor = tensor.cuda() should work.