Solved by Sayed_Nadim in post #2 
              
              
                use y.item() instead of y. For example, 
import torch

x = torch.arange(0, 9)
print("cpu ", x)
x = x.to(0)
print("gpu ", x)
y = torch.max(x)
print("max is ", y.item())

will give you, 
cpu  tensor([0, 1, 2, 3, 4, 5, 6, 7, 8])
gpu  tensor([0, 1, 2, 3, 4, 5, 6, 7, 8], device='cuda:0')
max is  8