In [1]: import torch
In [2]: device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
In [3]: rand_input = torch.tensor(data=torch.Tensor(1, 3, 80, 170), device=device, requires_grad=True)
In [4]: rand_input.device
Out[4]: device(type='cpu')
In [5]: device
Out[5]: device(type='cuda')
As can be seen when trying to create a tensor using the above way, even after specifying the device to be CUDA the returned tensor device type is CPU.
Am I missing something here? This does not seem like expected behaviour.