This should not be the case, if you are using a GPU and your code snippet works for me locally:


model = RNN(1, 1, 1, 1, 1)
print(next(model.parameters()).is_cuda)
> False
print(model.init_hidden(1))
> (tensor([[[0.]]]), tensor([[[0.]]]))

model.to('cuda')
print(next(model.parameters()).is_cuda)
> True
print(model.init_hidden(1))
> (tensor([[[0.]]], device='cuda:0'), tensor([[[0.]]], device='cuda:0'))

Also, you shouldn’t use the .data attribute, as it might have unwanted side effects (should be unrelated to your current issue).