torch version == 1.10.1
device = 'cuda:0'
If I try:
x = torch.Tensor([1.0], device=device)
I got the following error:
RuntimeError: legacy constructor expects device type: cpu but device type: cuda was passed
What am I doing wrong ?
I solved this by doing:
x = torch.Tensor([1.0]).to(device)
which works, but I would like to know why I can directly initialize the Tensor on GPU device.
This error occurs only with torch.Tensor
The following works:
x = torch.zeros(1, device=device) y = torch.ones(1, device=device)