快捷方式

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 完整的開發者文件

檢視文件

教學課程

取得針對初學者和進階開發者的深入教學課程

檢視教學課程

資源

尋找開發資源並獲得您問題的解答

檢視資源