PyTorch 학습 프로파일링 시 GPU 정지를 피하는 방법에 대한 기술적 노트입니다.
PyTorch 학습의 프로파일링에는 측정이 실행 행동에 영향을 미칠 수 있는 흥미로운 문제점이 있습니다. 예를 들어, <code>torch.cuda.synchronize()</code>를 사용하면 더 깨끗한 타이밍 경계를 제공하지만, 비동기 CUDA 작업에 동기화 포인트를 추가합니다. 대신 선택된 경계 주위에 CUDA 이벤트를 사용하면 비동기 작업의 동기를 강제하지 않고 타이밍을 캡처할 수 있습니다. 이 기사는 PyTorch 프로파일러와 Nsight와 함께 사용할 수 있는 가벼운 첫 번째 접근 방법으로 제시됩니다.
A technical note on profiling PyTorch training without stalling the GPU.
Profiling PyTorch training presents an interesting challenge as measuring can alter the run's behavior. For instance, using <code>torch.cuda.synchronize()</code> provides cleaner timing boundaries but also introduces synchronization points in an asynchronous CUDA workload. An alternative approach is to utilize CUDA events around selected boundaries to capture timing without enforcing synchronization. This article discusses a lightweight method before diving into more in-depth operator-level profiling.