Search notes:

torch.Tensor.to()

import torch

T = torch.tensor( [ [1.1 , 2.2] , [3.3 , 4.4] ])
print(T.device) # cpu

if torch.cuda.is_available:
   print('cuda is available')
   T = T.to('cuda') 
   print(T.device) # cuda:0

Index