torch.compiler.cudagraph_mark_step_begin#
- torch.compiler.cudagraph_mark_step_begin()[source]#
指示推断或训练的新迭代即将开始。
CUDA Graphs 将释放先前迭代的张量。每次调用 torch.compile 时都会开始一个新的迭代,只要没有待处理且尚未调用的 backward。
如果此启发式方法不正确,例如在以下示例中,请使用此 API 手动标记。
@torch.compile(mode="reduce-overhead") def rand_foo(): return torch.rand([4], device="cuda") for _ in range(5): torch.compiler.cudagraph_mark_step_begin() rand_foo() + rand_foo()
有关更多详细信息,请参阅 torch.compiler_cudagraph_trees