学习使用Nsight system分析Cuda应用。
容器中nsys
在容器内用nsys指令时,如果权限不够会无法调用perf_event_open的系统调用。解决方案参考Container Support on Linux Servers。
最简单的方法是在启动容器时加一条--privileged=true。如果要更安全的方式参考上面的文档。
nsys的参数
一些实用的参数。所有参数参考文档NVIDIA Nsight Systems user guide。
-w (--show-output)- 设置为true,会保留程序的stdout和stderr的输出
-t (--trace)- 可选项
cuda, nvtx, cublas, cublas-verbose, cusparse, cusparse-verbose, cudnn, opengl, opengl-annotations, openacc, openmp, osrt, mpi, nvvideo, vulkan, vulkan-annotations, dx11, dx11-annotations, dx12, dx12-annotations, oshmem, ucx, wddm, nvmedia, none - 默认值
cuda, opengl, nvtx, osrt - 设置要监视的api
- 可选项
-c (--capture range)- 可选项
none, cudaProfilerApi, hotkey, nvtx - 默认值
none - 设置从什么时候开始profiling
- 可选项
--cudabacktrace- 可选项
all, none, kernel, memory, sync, other - 启用回溯收集
- 对性能影响很大
- 可选项
--cuda-memory-usage- 默认false。设置为true后会profiling内存开销。
- 对性能影响很大
-f (--force-overwrite)- 默认为false。设置为true后强制覆盖原有的同名输出文件