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
。