CUDA:(五)Nvidia Visual Profiler (Nvidia自带内核执行代码分析软件)

我们都知道CUDA提供了一种提供了一种提高并行计算应用性能的有效方法,但是有时候会出现的一个问题是:即使我们使用了CUDA,即使用了代码并行操作,但是代码的时间消耗并没有有效减少,还有可能因为代码书写的原因导致运行时间更长,这是有可能的。

在这种情况下,我们就需要可视化代码哪一部分耗时最长,NVIDIA在安装时,也附带了标准的CUDA安装,该工具称为Nvidia Visual Profiler,可以使用nvvp启动这个软件。

nvvp

在这里插入图片描述如果能够看到这个上述窗口,O(∩_∩)O哈哈~基本上也就是成功一半。

然后选择file->New Session
在这里插入图片描述
在File位置选择对应的可执行文件,然后Next->Finish
就在你以为胜利就在眼前的时候,会出现如下Warning:

nvprof log: /home/felaim/nvvp_workspace/.metadata/.plugins/com.nvidia.viper/launch/0/nvprof_11779.log
==11779== 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 
==11779== Warning: Some profiling data are not recorded. Make sure cudaProfilerStop() or cuProfilerStop() is called before application exit to flush profile data.

主要问题,提取出来,还是权限问题

Warning: ERR_NVGPUCTRPERM - The user does not have permission to profile on the target device.

NVIDIA官网给出了解决方案:https://developer.nvidia.com/nvidia-development-tools-solutions-ERR_NVGPUCTRPERM-permission-issue-performance-counters#SolnAdminTag

在这里插入图片描述
在这里插入图片描述LZ按照官网可以尝试一下

modprobe nvidia NVreg_RestrictProfilingToAdminUsers=0

但是好像重新启动nvvp,并没有什么效果,第二方案,使用sudo权限:
在这里插入图片描述
出现了以下问题:

command not found

换句话说,问题可以总结成:执行sudo命令时command not found

问题的原因: 在编译sudo包的时候默认开启了- -with-secure-path选项。

方法1: 在/etc/sudoers文件内增加这么一行:Defaults secure_path=”/bin:/usr/bin:/usr/local/bin:…”, 把要用的命令path包括进去。

方法2: 用命令的绝对路径。

方法3: 使用sudo的env选项,像这样sudo env PATH=$PATH cmd.sh。

方法4: 把脚本拷贝或链接到系统$PATH中。

方法5: 重新编译sudo,不带–with-secure-path选项了.(终极解决办法)。

LZ这边选择第二种,先看下效果!查找nvvp的绝对路径

which nvvp

在这里插入图片描述

sudo /usr/local/cuda-10.1/bin//nvvp

在这里插入图片描述具体各个参数什么含义,小伙伴们可以自己研究下。

参考链接:

  1. https://blog.csdn.net/xueli1991/article/details/72818921

PS:
今天疫情情况,明天要破两万的节奏。。。
在这里插入图片描述在这里插入图片描述
昨天去了几个药店只买到10个口罩,分给妹妹家五个,还剩5个,但是看香港专家的预测,模型暂时还没收敛,还属于发散状态,只是希望这场疫情快点到达终点!

武汉加油!湖北加油!中国加油!

发布了300 篇原创文章 · 获赞 203 · 访问量 59万+

猜你喜欢

转载自blog.csdn.net/Felaim/article/details/104159065
今日推荐