快捷方式

torch.compiler.cudagraph_mark_step_begin

torch.compiler.cudagraph_mark_step_begin()[源代码][源代码]

指示新的推理或训练迭代即将开始。

CUDA Graphs 将释放先前迭代的张量。每次调用 torch.compile 时都会开始新的迭代,只要没有尚未调用的待处理反向传播。

如果该启发式方法是错误的,例如在以下示例中,请使用此 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

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源