做 CUDA 开发,用 nvprof 命令行分析性能时报错:
==14973== Warning: ERR_NVGPUCTRPERM - The user does not have permission to profile on the target device. See the following link for instructions to enable permissions and get more information: https://developer.nvidia.com/ERR_NVGPUCTRPERM
==14973== Profiling application: ./main
==14973== Profiling result:
No events/metrics were profiled.
==14973== Warning: Some profiling data are not recorded.
这是因为权限不够
- 所以,查看nvvp路径
$ which nvvp
/usr/local/cuda-11.2/bin/nvvp
- 把
/usr/local/cuda-11.2/bin
加到Defaults secure_path
后面
$ sudo su
$ vim /etc/sudoers
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/cuda-11.2/bin"
保存退出:wq!
- 可以使用啦,只需要前面加个sudo
sudo nvprof --metrics branch_efficiency ./main