You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CUDA新手使用Nsight Systems替代nvprof获取性能分析信息的问题

CUDA性能分析:从nvprof迁移到Nsight Systems CLI的问题

问题描述

刚接触CUDA开发,尝试做代码性能分析时,原计划用nvprof工具,却遇到错误:

======== Warning: This version of nvprof doesn't support the underlying device, GPU profiling skipped

查资料得知nvprof已被弃用,改用Nsight Systems CLI。执行nsys nvprof ./myapp后生成了report1.nsys-rep和report1.sqlite文件,想知道怎么用这些文件获取类似nvprof的性能分析信息,同时确认nsys nvprof ./myapp命令是否正确,有没有更合适的命令变体。

环境信息

  • 系统:搭载Ubuntu 20.04的WSL
  • NVIDIA Nsight Systems版本:2023.1.2.43-32377213v0
  • Nvprof版本:Release version 10.1.243 (21)
  • NVCC版本:Cuda compilation tools, release 10.1, V10.1.243

已尝试命令及输出

执行nsys profile --stats=true ./diverged后的输出:

Generating '/tmp/nsys-report-04e5.qdstrm'
[1/8] [========================100%] report2.nsys-rep
[2/8] [========================100%] report2.sqlite
[3/8] Executing 'nvtx_sum' stats report
SKIPPED: .../sum_reduction/report2.sqlite does not contain NV Tools Extension (NVTX) data.
[4/8] Executing 'osrt_sum' stats report

 Time (%)  Total Time (ns)  Num Calls   Avg (ns)    Med (ns)   Min (ns)  Max (ns)   StdDev (ns)       Name
 --------  ---------------  ---------  ----------  ----------  --------  ---------  -----------  --------------
     74.7        364907400          6  60817900.0  72485919.0   4489170  100201745   42231058.9  poll
     24.3        118728446        345    344140.4     81962.0       541   10034413    1039273.8  ioctl
      0.6          2840826          9    315647.3    449904.0      2254     535093     236455.8  read
      0.2           920219          2    460109.5    460109.5    105991     814228     500799.2  sem_timedwait
      0.1           471795          2    235897.5    235897.5     70382     401413     234074.3  pthread_create
      0.1           310682         25     12427.3      8907.0      2785      95078      18330.8  mmap
      0.0            84580          9      9397.8     10049.0      1473      15419       4316.1  open
      0.0            80611         13      6200.8      4559.0      1382      17002       5451.1  fopen
      0.0            65704          3     21901.3     21310.0     20649      23745       1630.5  write
      0.0            48833         26      1878.2        70.5        60      46898       9182.3  fgets
      0.0            18413          6      3068.8      1738.0      1182       8455       2815.7  fclose
      0.0             8245          1      8245.0      8245.0      8245       8245          0.0  pipe2
      0.0             7233          2      3616.5      3616.5      1853       5380       2494.0  munmap
      0.0             6662          5      1332.4      1533.0       351       1853        579.3  fcntl

[5/8] Executing 'cuda_api_sum' stats report
SKIPPED: .../sum_reduction/report2.sqlite does not contain CUDA trace data.
[6/8] Executing 'cuda_gpu_kern_sum' stats report
SKIPPED: .../sum_reduction/report2.sqlite does not contain CUDA kernel data.
[7/8] Executing 'cuda_gpu_mem_time_sum' stats report
SKIPPED: .../sum_reduction/report2.sqlite does not contain GPU memory data.
[8/8] Executing 'cuda_gpu_mem_size_sum' stats report
SKIPPED: .../sum_reduction/report2.sqlite does not contain GPU memory data.

解决方案与说明

1. nsys nvprof命令的正确性

nsys nvprof ./myapp是Nsight Systems为兼容nvprof用户提供的过渡命令,会模拟nvprof的行为生成报告,但本质基于Nsight的采集逻辑。如果需要更精准的CUDA性能数据,建议直接使用nsys profile的完整参数。

2. 如何获取类似nvprof的性能分析信息

(1)生成包含CUDA数据的报告

你当前执行的命令未采集到CUDA数据,是因为默认参数未开启CUDA相关采集选项。需显式指定采集CUDA事件,命令如下:

nsys profile --cuda=true --stats=true ./myapp

该命令会强制开启CUDA API和内核的采集,生成的报告中会包含cuda_api_sum、cuda_gpu_kern_sum等GPU性能数据,对应nvprof的内核执行时间、内存操作统计等信息。

(2)查看生成的报告文件

  • *.nsys-rep文件:用Nsight Systems桌面版打开,可图形化查看完整时间线、内核执行详情、API调用流程,直观掌握GPU和CPU的执行同步情况。
  • *.sqlite文件:用命令行分析的话,可通过nsys stats提取特定数据,示例:
    # 提取CUDA内核统计数据
    nsys stats --report cuda_gpu_kern_sum report1.sqlite
    # 提取CUDA API调用统计
    nsys stats --report cuda_api_sum report1.sqlite
    
    得到的结果类似nvprof--print-gpu-trace或--print-api-trace的文本格式统计。

3. 关键注意事项

  • 你的CUDA版本为10.1,需确保WSL环境能正确识别GPU(Windows主机需安装正确的NVIDIA驱动,WSL可访问GPU),否则采集会失败。
  • 如果仍未采集到CUDA数据,检查应用是否真的执行了CUDA内核,或添加--trace=cuda,nvtx参数强制追踪所有CUDA相关事件:
    nsys profile --trace=cuda,nvtx --stats=true ./myapp
    

内容的提问来源于stack exchange,提问作者dru10

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 03:57:04