快捷方式

torch.Tensor.cuda

Tensor.cuda(device=None, non_blocking=False, memory_format=torch.preserve_format) Tensor

返回此对象在 CUDA 内存中的副本。

如果此对象已在 CUDA 内存中且位于正确的设备上,则不执行复制,并返回原始对象。

参数
  • device (torch.device) – 目标 GPU 设备。默认为当前 CUDA 设备。

  • non_blocking (bool) – 如果 True 且源在 pinned 内存中,则复制将相对于主机异步执行。否则,此参数无效。默认值:False

  • memory_format (torch.memory_format, optional) – 返回的 Tensor 的所需内存格式。默认值:torch.preserve_format

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得您的问题解答

查看资源