vscode远程调试Linux CUDA程序
2 使用remote-ssh登陆到远程的linux服务器,登陆以后看看安装的插件,需要在远程linux服务器也同时安装插件。确保提到的三个插件在远程端是可以用的。3 确保在远程linux服务器已经安装了cuda编译器,没有装的话点下面的链接,输入命令 nvcc -V查看安装情况。4 新建一个目录用来测试,例如~/my_cuda,用vscode打开此目录。1 本地安装插件:remote-ssh,Mi
·
参考了:CUDA 01 | 第一个程序 - 知乎 (zhihu.com)
1 本地安装插件:remote-ssh,Microsoft C/C++与NVIDIA Nsight Visual Studio Code Edition。
2 使用remote-ssh登陆到远程的linux服务器,登陆以后看看安装的插件,需要在远程linux服务器也同时安装插件。确保提到的三个插件在远程端是可以用的。
3 确保在远程linux服务器已经安装了cuda编译器,没有装的话点下面的链接,输入命令 nvcc -V查看安装情况。
CUDA Toolkit 11.7 Update 1 Downloads | NVIDIA Developerhttps://developer.nvidia.com/cuda-downloads
langke@ubuntu:~/my_cuda$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Sun_Feb_28_22:34:44_PST_2021
Cuda compilation tools, release 10.2, V10.2.300
Build cuda_10.2_r440.TC440_70.29663091_0
4 新建一个目录用来测试,例如~/my_cuda,用vscode打开此目录
5 在.vscode下新建lauch.json,内容如下:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "CUDA C++: Launch",
"type": "cuda-gdb",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
//"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "nvcc build active file",
"postDebugTask": "delete nvcc output file",
}
]
}
6 新建tasks.json,内容为:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "nvcc build active file",
"command": "/usr/local/cuda-10.2/bin/nvcc",
"args": [
"${file}",
"-g",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "delete nvcc output file",
"command": "rm",
"args": [
"${fileDirname}/${fileBasenameNoExtension}"
],
"presentation": {
"reveal": "silent"
},
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
7 新建test.cu,输入内容:
#include <iostream>
int main(int argc, char **argv)
{
printf("cuda test\n");
getchar();
return 0;
}
8 把窗口切换到test.cu,点击CUDA调试按钮就可以运行了。
更多推荐
已为社区贡献2条内容
所有评论(0)