跳到主要内容
CUDA编程与算子优化

第8章:性能分析工具链

掌握 Nsight Systems、Nsight Compute 和 PyTorch Profiler 三大性能分析工具,建立系统化的性能诊断能力

Nsight Systems Nsight Compute PyTorch Profiler 性能分析

本章简介

优化的前提是精准诊断——不会用 Profiler 的优化都是盲猜。本章掌握 AI Infra 领域三大核心性能分析工具。

Nsight Systems是 CPU-GPU 全链路分析利器,用于识别 GPU idle gap 的来源(CPU 瓶颈、通信等待、Kernel Launch Overhead),抓取训练 iteration 的 trace 并进行宏观分析。

Nsight Compute是 Kernel 级下钻分析工具,重点掌握 SOL(Speed of Light)面板解读——判断 Kernel 是 Memory Bound 还是 Compute Bound,以及 Shared Memory、Warp State 等面板的使用和两个 Kernel 版本的对比分析。

PyTorch Profiler通过 torch.profiler 与 TensorBoard 集成,识别耗时最长的算子,评估 torch.compile 的编译收益。

动手实验:用 Nsight Systems 抓一次训练 iteration 指出 GPU idle gap 来源,用 Nsight Compute 对比 Reduce 三版本的性能报告。