Segmentation fault occured when using cuda-gdb in wsl2

hello everyone, i have some trouble with cuda-gdb, here is my environment:
win 10
Ubuntu 20.04 on wsl2
nvidia driver 527.37 on windows
CUDA Version: CUDA Version: 12.0
cudatoolkit 12.0 on wsl2
I wang to debug cuda file in vscode, here is my launch.json:

    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit:
    "version": "0.2.0",
    "configurations": [
            "name": "CUDA C++: Launch",
            "type": "cuda-gdb",
            "request": "launch",
            "program": "${workspaceFolder}/test",
            // "debuggerPath":"/usr/local/cuda-12/bin/cuda-gdb",
            "name": "CUDA C++: Attach",
            "type": "cuda-gdb",
            "request": "attach"

I use this command to compile my code :

nvcc -arch=compute_89 -code=sm_89 -g -G -o test

when cuda-gdb debugging is executed to the kernel function, the following error will be reported

Hi, @koi20000

According to CUDA on WSL User Guide, debugger support for Ada in wsl was not ready in CUDA12.0. Please try with our latest cuda. Thanks !

Thanks for your reply, I updated the cuda tookit version to V12.3.103
But the error still exists

OK. Have you ever tried using cuda-gdb(without VSCode) to debug the sample directly?

I’ve tried it, the screenshot above is the error when using cuda-gdb in the terminal

Thanks. Is it possible to provide us the sample code you debug ? Then we can reproduce and investigate the failure.

sure, just a simple code for testing cuda-gdb

#include <stdio.h>
// nvcc -arch=compute_89 -code=sm_89 -g -G -o test
__global__ void hello_world(void) {
    int x = threadIdx.x;
    int y = threadIdx.y;
    int z = threadIdx.z;
    printf("GPU: Hello world at %d %d %d\n", x, y, z);

int main() {
    dim3 grid(1, 1, 1), block(3, 4, 1);
    hello_world<<<grid, block>>>();
    return 0;

Thanks @koi20000 . I tried your code and can debug without issue. From the screenshot, you didn’t set any breakpoint, just press “continue”, the sample should run to end, but you met error.

Can the sample run successfully without cuda-gdb ?

Yes, the code run successfully without cuda-gdb

Did you upgrade CUDA driver on Windows also ? What’s the driver version now ?

Also can you try another CUDA sample to see if this is also reproduced ?

Thanks !

My driver version is 546.17 now.

I also tried to run the other code and the same error is still there, running it directly can get the correct result, but using cuda-gdb will report the error

Hi @koi20000
To help us identify the issue, could you share additional information with us?

  • Enable additional logging and share the result logs with us.
    • Add NVLOG_CONFIG_FILE variable pointing the nvlog.config file (attached). E.g.: NVLOG_CONFIG_FILE=${HOME}/nvlog.config
      nvlog.config (539 Bytes)

    • Run the debugging session.

    • You should see the /tmp/debugger.log file created - could you share it with us?

debugger.log (112.2 KB)

Hi @koi20000
Could you please check that you have enabled the debugging in the registry? (CUDA-GDB )

  • Make sure this capability is enabled via the registry key >HKEY_LOCAL_MACHINE\SOFTWARE\NVIDIA Corporation\GPUDebugger\EnableInterface set to (DWORD) 1.

I added the corresponding key to the registry.

Now the error is below

the file is
debugger.log (82.3 KB)

Hi @koi20000
Could you also try re-installing the GPU driver (after setting the register key)? If this doesn’t help - would you be able to share your application with us, so we can reproduce this locally?

I updated the cuda driver on windows to 546.29 and still have the error in the previous screenshot.
My code is in the previous REPLY.
Currently I migrated the code to a linux server and it works fine, thanks for your time!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.