I usually just use the “to” method:
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

# Assuming that we are on a CUDA machine, this should print a CUDA device:

print(device)

model_cuda.to(device) # This replaces: model_cuda = model_cuda.cuda()

Please see here for more information:
https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html#training-on-gpu 7