torch.Tensor.cuda#
- Tensor.cuda(device=None, non_blocking=False, memory_format=torch.preserve_format) Tensor#
返回此对象在 CUDA 内存中的副本。
如果此对象已在 CUDA 内存中并且位于正确的设备上,则不会执行复制,并返回原始对象。
- 参数
device (
torch.device, optional) – 目标 GPU 设备。默认为当前的 CUDA 设备。non_blocking (bool, optional) – 如果为
True且源在已固定内存中,则复制将相对于主机异步进行。否则,该参数无效。默认值:False。memory_format (
torch.memory_format, optional) – 返回的 Tensor 的所需内存格式。默认值:torch.preserve_format。