I’m developing CUDA application on Windows 1124H2 using WSL2 with Ubuntu 22.04, and debugging with VS Code.
currently I can compile and run the program normally, but if I run it with cuda-gdb, it gets stuck. Then pausing the program, I found that it stops at the function return ::cudaLaunchKernel((const void *)func, gridDim, blockDim, args, sharedMem, stream);
I have :
Verified that /usr/local/cuda-12.9 is installed correctly in WSL2,
Added cuda-gdb to my environment path,
Enabled the registry key HKEY_LOCAL_MACHINE\SOFTWARE\NVIDIA Corporation\GPUDebugger\EnableInterface with DWORD 1 on the Windows side,
Ensured the GPU is visible to WSL2 with nvidia-smi.
±----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.82.02 Driver Version: 581.15 CUDA Version: 13.0 |
±----------------------------------------±-----------------------±---------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 5090 D On | 00000000:01:00.0 On | N/A |
| 32% 36C P0 70W / 575W | 17890MiB / 32607MiB | 1% Default |
| | | N/A |
±----------------------------------------±-----------------------±---------------------+
±----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
±----------------------------------------------------------------------------------------+
±----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 24 G /Xwayland N/A |
±----------------------------------------------------------------------------------------+
test@tools-win-gb20x:~$ cuda-gdb ./test
NVIDIA (R) cuda-gdb 12.9
Portions Copyright (C) 2007-2025 NVIDIA Corporation
Based on GNU gdb 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type “show copying” and “show warranty” for details.
This CUDA-GDB was configured as “x86_64-pc-linux-gnu”.
Type “show configuration” for configuration details.
For bug reporting instructions, please see: https://forums.developer.nvidia.com/c/developer-tools/cuda-developer-tools/cuda-gdb.
Find the CUDA-GDB manual and other documentation resources online at: https://docs.nvidia.com/cuda/cuda-gdb/index.html.
For help, type “help”.
Type “apropos word” to search for commands related to “word”…
Reading symbols from ./test…
(cuda-gdb) b 5
Breakpoint 1 at 0x8d9f: file /home/test/test.cu, line 9.
(cuda-gdb) r
Starting program: /home/test/test
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/libthread_db.so.1”.
[New Thread 0x7ffff59ff000 (LWP 1896)]
[New Thread 0x7fffeffff000 (LWP 1897)]
[Detaching after fork from child process 1898]
[New Thread 0x7fffef7fe000 (LWP 1907)]
[Thread 0x7fffef7fe000 (LWP 1907) exited]
[New Thread 0x7fffef7fe000 (LWP 1908)]
[Detaching after vfork from child process 1909]
[Switching focus to CUDA kernel 0, grid 1, block (0,0,0), thread (0,0,0), device 0, sm 0, warp 0, lane 0]
CUDA thread hit Breakpoint 1, kernel<<<(10,1,1),(10,1,1)>>> () at test.cu:6
6 int x = threadIdx.x + blockDim.x * blockIdx.x;
(cuda-gdb) s
n8 printf(“hello from thread %d \n”,x);
(cuda-gdb) n
9 }
(cuda-gdb) si
0x0000000701161ed0 9 }
(cuda-gdb) ni
0x0000000701161ee0 9 }
This is very strange. I use the same command as you in the terminal, it also freezes there.
NVIDIA (R) cuda-gdb 12.9
Portions Copyright (C) 2007-2025 NVIDIA Corporation
Based on GNU gdb 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This CUDA-GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://forums.developer.nvidia.com/c/developer-tools/cuda-developer-tools/cuda-gdb>.
Find the CUDA-GDB manual and other documentation resources online at:
<https://docs.nvidia.com/cuda/cuda-gdb/index.html>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/akiame/code/build/TEST/CUDA...
(cuda-gdb) b 5
Breakpoint 1 at 0x403cc4: file /home/akiame/code/TEST/test.cu, line 6.
(cuda-gdb) r
Starting program: /home/akiame/code/build/TEST/CUDA
warning: File "/usr/local/gcc-14.3/lib64/libstdc++.so.6.0.33-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /usr/local/gcc-14.3/lib64/libstdc++.so.6.0.33-gdb.py
line to your configuration file "/home/akiame/.config/gdb/cuda-gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/akiame/.config/gdb/cuda-gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff55ff000 (LWP 38997)]
[New Thread 0x7fffeffff000 (LWP 38998)]
[Detaching after fork from child process 38999]
[New Thread 0x7fffef3ff000 (LWP 39008)]
[Thread 0x7fffef3ff000 (LWP 39008) exited]
[New Thread 0x7fffef3ff000 (LWP 39009)]
[Detaching after vfork from child process 39010] <---it stuck at this piece of code.
Hi,recently I upgraded the cudatoolkit in WSL2 to version 13.0 and updated the GPU driver on the host machine to 581.42. When I ran the previous example again, it still froze in the same way. When debugging from the command line using cuda-gdb, it gets stuck at [Detaching after vfork from child process 5319]. However, when debugging through VSCode, it no longer freezes at return ::cudaLaunchKernel((const void *)func, gridDim, blockDim, args, sharedMem, stream);
but instead gets stuck at cudaDeviceSynchronize(); or other statements that trigger device synchronization.