使用了下面前两种方法都没成功,不适用于我。
方法1:针对nvprof的
解决 nvprof 报错ERR_NVGPUCTRPERM - The user
修改sudoers改了还是不行
方法2:管理员权限打不开
dell@dell-Precision-5820-Tower-X-Series:~$ cd /usr/local/cuda-11.2/nsight-compute-2020.3.0 dell@dell-Precision-5820-Tower-X-Series:/usr/local/cuda-11.2/nsight-compute-2020.3.0$ sudo su [sudo] dell 的密码: root@dell-Precision-5820-Tower-X-Series:/usr/local/cuda-11.2/nsight-compute-2020.3.0# nv-nsight-cu Command 'nv-nsight-cu' not found, but can be installed with: apt install nsight-compute root@dell-Precision-5820-Tower-X-Series:/usr/local/cuda-11.2/nsight-compute-2020.3.0# nuc-ui
nuc-ui:未找到命令
dell@dell-Precision-5820-Tower-X-Series:~$ modprobe -r nvidia_uvm nvidia_drm nvidia_modeset nvidia-vgpu-vfio nvidia modprobe: ERROR: ../libkmod/libkmod-module.c:799 kmod_module_remove_module() could not remove 'nvidia_uvm': Operation not permitted modprobe: ERROR: ../libkmod/libkmod-module.c:799 kmod_module_remove_module() could not remove 'nvidia_drm': Operation not permitted modprobe: FATAL: Module nvidia_modeset is in use.
Linux环境下重装NVIDIA驱动报错kernel module (nvidia_modeset) in use问题分析 | Heary's Blog
linux强制卸载模块 - 知乎 (zhihu.com)
dell@dell-Precision-5820-Tower-X-Series:~$ lsmod Module Size Used by nvidia_uvm 1032192 0 nvidia_drm 57344 0 nvidia_modeset 1183744 1 nvidia_drm nvidia 34942976 2 nvidia_uvm,nvidia_modeset
官网提供的解决方法:
开启GPU的开发模式
Linux 418.43 or later driver会默认开启保护模式,最简单的验证方法是使用nvprof来测试程序,如果出现了ERR_NVGPUCTRPERM: Permission issue with Performance Counters,则说明保护模式已经开启。
NVIDIA Development Tools Solutions - ERR_NVGPUCTRPERM: Permission issue with Performance Counters | NVIDIA Developer
成功解决的步骤
1、查看ncu路径
$ which ncu
/usr/local/cuda-11.2/bin/ncu
2、把/usr/local/cuda-11.2/bin加到Defaults secure_path后面
$ sudo su
$ vim /etc/sudoers
3、sudo ncu-ui 报如下错误:
直接输入 ncu-ui 可以打开compute,就是launch时核函数会报没有权限的错误;
命令执行如下:
dell@dell-Precision-5820-Tower-X-Series:~$ ncu-ui ********BP-RCM----nFrame:1, FrameLen=4096, mea=8192, iteration=1 [cudaEvent]*********** dell@dell-Precision-5820-Tower-X-Series:~$ sudo ncu-ui No protocol specified qt.qpa.xcb: could not connect to display :10.0 qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: xcb. /usr/local/cuda-11.2/bin/../nsight-compute-2020.3.0/host/linux-desktop-glibc_2_11_3-x64/ncu-ui:行 16: 3025862 已放弃 (核心已转储) "$NV_AGORA_PATH/CrashReporter" "NVIDIA Nsight Compute" "NVIDIA Nsight Compute" "2020.3.0.0 (build 29307467) (public-release)" "$NV_AGORA_PATH/ncu-ui.bin" "$@"
这是因为Xserver默认情况下不允许别的用户的图形程序的图形显示在当前屏幕上. 如果需要别的用户的图形显示在当前屏幕上, 则应以当前登陆的用户, 也就是切换身份前的用户执行如下命令
xhost +
可参考
Linux系统下解决“No protocol specified“报错_深度科研的博客-CSDN博客_linux no protocol specified



