I’m glad it solved the error! 


The error was raised in my environment. If you have executed the script in Colab, the error message might have been lost?


Usually, every tensor, which should be pushed to the same device as the model parameters, but doesn’t require gradients, should be registered as a buffer. On the other hand, if the tensor requires gradients, use nn.Parameter.