一. nvcc
1. 报错: nvcc fatal : Cannot find compiler 'cl.exe' in PATH
因为没有识别到VS的路径导致报错,将C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64添加到高级系统设置---环境变量中,然后重启电脑即可。一定要重启。
2. 管理员身份运行cmd
输入 [nvcc -V] 可查询当前cuda版本信息
3. 创建项目库
方法1:
①转至.cu文件所在文件夹[cd D:\……\GPU]
②输入语句:nvcc kernel.cu -o Demo.exe
$ cd D:\……\cudatest\cudatest //kernel.cu所在文件夹路径
$ nvcc kernel.cu -o Demo.exe
方法2:
VS中直接编译,然后cd到编译出的exe所在文件夹。
二. nvprof
$ nvprof Demo
nvprof指标分析只支持算力7.5以下的显卡,7.5也不支持。能整体分析,但不能给具体指标。
后面改为使用Nsight Compute Common-line Interface(Cli命令行)抓取指标

三、nv-nsight-cu-cli(ncu)
nsys profile --stats=true ./cudatest.exe
第一次执行出现了报错:
Unexpected exception thrown while launching the application.
Dynamic exception type: class std::range_error
std::exception::what: bad conversion
查询原因是nsys的版本过旧,和cuda11.6不匹配,下载安装nsys2024.1.1,并添加环境变量+重启之后,运行代码,即可通过。
四. 示例

或(VS中编译,我编译生成的cudatest_Demo.exe在D:\……\TestDemo\cudatest\x64\Release文件夹下)

nsys

推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://sg.hqyman.cn/post/8974.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
打赏

微信支付宝扫一扫,打赏作者吧~
休息一下~~