1、环境介绍
在linux系统中安装vscode后配置cuda+c/c++编程环境进行学习cuda编程,笔者使用的arm架构的jetson agx orin开发套件,其中已经安装好的cuda11,cudnn, TensorRT,opencv等一系列开发工具(不需要你再进行安装确实很省事)。直接连接的显示屏,并未进行电脑远程链接。根据广大网友推荐,在其中直接安装vscode进行代码的调试。
2、配置过程
2.1、下载安装vscode
vdcode已经支持arm架构的,不需要在下载vscode-oss,直接在官网上下载arm64的文件,安装即可。
官网https://code.visualstudio.com/Download,下载deb的Arm64,网上有很多安装步骤,几行命令。
2.2、环境配置
需要的插件:c/c++。
Nsight Visual Studio Code Edition。
主要是上面两个code runner。
c_cpp_properties.json文件
strl+shift+P->选择C/C++:Edit Configurations(JSON)
{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**",],"defines": [],"compilerPath": "/usr/local/cuda-11/bin/nvcc",//使用的是nvcc编译"cStandard": "c17",//保持默认,跳出来的是c17,不是c11"cppStandard": "gun++17","intelliSenseMode": "linux-gcc-arm64"}],"version": 4}
launch.json
不知道怎么点的,参考https://blog.csdn.net/guzhao9901/article/details/115352574
{"version": "0.2.0","configurations": [{"name": "CUDA C++: Launch","type": "cuda-gdb","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}","debuggerPath": "/usr/local/cuda-11"/bin/cuda-gdb",//找对路径"preLaunchTask": "build"}]}
3、tasks.json
注意:和x86架构等其它不一样
{"version": "2.0.0","tasks": [{"label": "build","type": "shell","command": "/usr/local/cuda-11/bin/nvcc","args": ["-g","-G","${file}","${fileDirname}/${fileBasenameNoExtension}"],"group":{"kind": "build","isDefault": true}}]}
3、总结
自己也配置了好久,最终成功运行test.cu文件,很多都是基于x86的,很多相关arm文献都并非免费。小白入坑也很久,最终还算是解决了。
4、参考链接
https://blog.csdn.net/oushaojun2/article/details/126836825,
https://blog.csdn.net/guzhao9901/article/details/115352574
https://blog.csdn.net/qq_37365470/article/details/126493972