"Start CUDA Debugging" in CMake project don't work

Hi nvidia guys, why nSight CUDA integrated source level debugger is not working in CMake type of project? This button just disabled. How can you fix this?

Hi, did you find out a solution for this? Do you know why in a cmake project the option is greyed out?

I’ve tried to build with -G:
target_compile_options(target-name PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-G -src-in-ptx>)

but it did not solve …

Hello, don’t know if you still have the issue, but I fixed with the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.8 FATAL_ERROR)

if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
    set(CMAKE_CUDA_ARCHITECTURES 52)
endif()

project(helloWorld_cuda_v2 VERSION 0.1.0)
set(CMAKE_BUILD_TYPE Debug)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS} "-g -G")  # enable cuda-gdb
endif()

include(CTest)
enable_testing()
enable_language(CUDA)

add_executable(helloWorld_cuda_v2 
                main.cpp
                hello.cu)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

Of course, in here I have 2 files, main.cpp and hello.cu.
And the launch.json is:

{
    // 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": "${workspaceFolder}/build/helloWorld_cuda_v2"
        },
        {
            "name": "CUDA C++: Attach",
            "type": "cuda-gdb",
            "request": "attach",
            "processId": "${command:cuda.pickProcess}"            
        }
    ]
}

Hope this can help.
I still have some issues with debugging arrays, but everything else works as expected.

Thanks for your reply,
Which version of VisualStudio are you using?
Which version of CMAKE?

CMAKE 3.25.1 and VSCode 1.76.0 on a Debian machine.

1 Like