MCPcopy Create free account
hub / github.com/pytorch/tutorials / copy_to_device_nonblocking

Function copy_to_device_nonblocking

intermediate_source/pinmem_nonblock.py:354–360  ·  view source on GitHub ↗
(*tensors)

Source from the content-addressed store, hash-verified

352
353# A loop that copies all tensors to cuda asynchronously
354def copy_to_device_nonblocking(*tensors):
355 result = []
356 for tensor in tensors:
357 result.append(tensor.to("cuda:0", non_blocking=True))
358 # We need to synchronize
359 torch.cuda.synchronize()
360 return result
361
362
363# Create a list of tensors

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected