graph — PyTorch 2.7 documentation (original) (raw)

class torch.cuda.graph(cuda_graph, pool=None, stream=None, capture_error_mode='global')[source][source]

Context-manager that captures CUDA work into a torch.cuda.CUDAGraph object for later replay.

See CUDA Graphs for a general introduction, detailed use, and constraints.

Parameters

Note

For effective memory sharing, if you pass a pool used by a previous capture and the previous capture used an explicit stream argument, you should pass the same stream argument to this capture.

Warning

This API is in beta and may change in future releases.