如何通过 nvprof 在短时间内分析 CUDA 应用程序?

How to profile the CUDA application for a short amount of time by nvprof?

我想通过 nvprof 生成一个极限配置文件。如何将分析时间限制为仅 5 秒?

nvprof 有一个 timeout 选项。来自 documentation :

A timeout (in seconds) can be provided to nvprof. The CUDA application being profiled will be killed by nvprof after the timeout. Profiling result collected before the timeout will be shown.

Note: Timeout starts counting from the moment the CUDA driver is initialized. If the application doesn't call any CUDA APIs, timeout won't be triggered.

您还可以标记 nvprof 应用的开始和结束时间点。这可以使用 cudaProfilerStart()cudaProfilerEnd() 明确地完成,或者以隐式的 RAII 方式使用生命周期 a cuda::profiling::scope 对象(来自我的 Modern C++ CUDA API wrappers)。

请记住,如果您使用 nvvp,请不要选中告诉它分析整个 运行 的复选框。