Solved by albanD in post #2 
              
              
                Hi, 
When you do x = x.to(device), you change the tensor x. 
Only the tensor that you created with requires_grad=True will have gradients computed. 
The x that you check is an intermediary Tensor and so will not have gradients. 
Note that you can do: x = torch.rand(3, device=device, requires_grad=Tr…