如何在Visual Studio Code中通过CMAKE构建的CUDA程序调试?
我正在尝试调试使用VS代码的测试程序,在Ubuntu 20中的Cmake。我主要提到CUDA调试器文档: https://docs.nvidia.com/nsight-visual-visual-studio-code-code-edition/cuda-debugger/index.htex.html 。 但是,我不确定如何在基于CMAKE的项目中编写正确的启动。 这是我的cmakelists.txt,
cmake_minimum_required(VERSION 3.2)
project(cudaDebug CXX CUDA)
find_package(CUDA REQUIRED)
add_executable(main main.cu)
这是我的启动。当我按F5开始调试时,由VS代码生成的JSON
{
"version": "0.2.0",
"configurations": [
{
"name": "CUDA C++: Launch",
"type": "cuda-gdb",
"request": "launch",
"program": "main.cu"
},
{
"name": "CUDA C++: Attach",
"type": "cuda-gdb",
"request": "attach"
}
]
}
,弹出错误信息:
main.cu: 346262241346234211351202243344270252346226207344273266346210226347233256345275225.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您必须更改以下行:
to
并选择VSCODE中的可执行文件(通常在底行,您还可以选择“构建目标”)。
还可以看一下:
I think you have to change the following line:
to
and select the executable in VSCode (usually on the bottom row where you can also select build targets).
Have also a look here:
https://vector-of-bool.github.io/docs/vscode-cmake-tools/debugging.html
您可以尝试将CMAKE版本更新为高于3.10,不再需要使用
find_package(cuda)
这是一个用于使用CUDA-GDB
的VSCODE和CMAKE的模板
cmakelists.txt
tasks.json
aumination.json
希望它可以帮助您:)
you can try to update your cmake version to higher than 3.10, which no longer need to use
find_package(CUDA)
here is one template for vscode and cmake to use cuda-gdb
CMakeLists.txt
tasks.json
launch.json
wish it could help you :)