I’m trying to debug a test program with VS CODE, CMake in Ubuntu 20. I referred mainly to the CUDA debugger document: https://docs.nvidia.com/nsight-visual-studio-code-edition/cuda-debugger/index.html.
However, I’m not sure about how to write a correct launch.json in a project based on CMake.
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 3.2)
project(cudaDebug CXX CUDA)
find_package(CUDA REQUIRED)
add_executable(main main.cu)
Here is my launch.json generated by VS CODE
{
"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"
}
]
}
When I press F5 to start debugging, an error information poped up:
main.cu: 346262241346234211351202243344270252346226207344273266346210226347233256345275225.
2
Answers
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
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 🙂