Solved by zetyquickly in post #4 
              
              
                At first you should check if CUDA devices are available. 
Then set the device variable with some value (e.g. 'cpu', 'cuda:0') and pass it to your_tensor.to() function. 
Note: set a constant string value for the device is not an only option (if you want use tensor.to() for transfering to device), you…