torch.cuda.device(device)
paddle.CUDAPlace(id)
其中 PyTorch 与 Paddle 的参数支持类型不一致,具体如下:
# PyTorch 写法 torch.cuda.device(torch.device('cuda')) # Paddle 写法 paddle.CUDAPlace(0) # 增加 index # PyTorch 写法 torch.cuda.device(torch.device('cuda', index=index)) # Paddle 写法 paddle.CUDAPlace(index)