Function Differences with torch.cuda.set_device

View Source On Gitee

torch.Tensor.cuda

torch.Tensor.cuda()

For more information, see torch.Tensor.cuda.

mindspore.set_context

mindspore.set_context(**kwargs)

For more information, see mindspore.set_context.

Differences

PyTorch: Copy Tenosr to cuda memory.

MindSpore:When setting the variable to device_target='GPU' or device_target='Ascend', both the network and Tensor will be automatically copied to the GPU/Ascend device.