All I do is,
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") torch.tensor([123,123]).to(device)
And