Their syntax varies slightly, but they are equivalent 11:




.to()
.cuda()




to('cuda')
cuda()


to('cuda:1')
cuda(device=1)


to('cpu')
cpu()



Note: the first row uses the default GPU (this can be set with torch.cuda.set_device()).