Cuda-gdb not working for kernel code under WSL2

Hello,
I am trying to debug a CUDA kernel under WSL2 and the cuda-gdb debugger is ignoring the GPU code.
Problem can be reproduced as follows:
Start with a fresh WSL2 installation and install CUDA toolkit as per instructions on the Nvidia website.
Go to the matrixMul sample folder.
Then:

robik@WSL2:/usr/local/cuda/samples/0_Simple/matrixMul$ sudo make clean dbg=1
rm -f matrixMul matrixMul.o
rm -rf …/…/bin/x86_64/linux/debug/matrixMul

robik@WSL2:/usr/local/cuda/samples/0_Simple/matrixMul$ sudo make dbg=1
/usr/local/cuda-11.4/bin/nvcc -ccbin g++ -I…/…/common/inc -m64 -g -G --threads 0 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_86,code=compute_86 -o matrixMul.o -c matrixMul.cu
nvcc warning : The ‘compute_35’, ‘compute_37’, ‘compute_50’, ‘sm_35’, ‘sm_37’ and ‘sm_50’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/local/cuda-11.4/bin/nvcc -ccbin g++ -m64 -g -G -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_86,code=compute_86 -o matrixMul matrixMul.o
nvcc warning : The ‘compute_35’, ‘compute_37’, ‘compute_50’, ‘sm_35’, ‘sm_37’ and ‘sm_50’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mkdir -p …/…/bin/x86_64/linux/debug
cp matrixMul …/…/bin/x86_64/linux/debug

robik@WSL2:/usr/local/cuda/samples/0_Simple/matrixMul$ sudo /usr/local/cuda/bin/cuda-gdb matrixMul
NVIDIA (R) CUDA Debugger
11.4 release
Portions Copyright (C) 2007-2021 NVIDIA Corporation
GNU gdb (GDB) 10.1
Copyright (C) 2020 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 GDB was configured as “x86_64-pc-linux-gnu”.
Type “show configuration” for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type “help”.
Type “apropos word” to search for commands related to “word”…
Reading symbols from matrixMul…
(cuda-gdb) b 44
Breakpoint 1 at 0xd20b: /usr/local/cuda-11.4/samples/0_Simple/matrixMul/matrixMul.cu:44. (2 locations)
(cuda-gdb) r
Starting program: /usr/local/cuda-11.4/samples/0_Simple/matrixMul/matrixMul
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/libthread_db.so.1”.
[Matrix Multiply Using CUDA] - Starting…
GPU Device 0: “Pascal” with compute capability 6.1

MatrixA(320,320), MatrixB(640,320)
[New Thread 0x7fffdffff000 (LWP 8942)]
[New Thread 0x7fffdd6fe000 (LWP 8943)]
Computing result using CUDA Kernel…

Thread 1 “matrixMul” hit Breakpoint 1, MatrixMulCUDA<32> (C=0x7081ec000, A=0x7080c0000, B=0x708124000, wA=320, wB=640) at matrixMul.cu:109
109 }
(cuda-gdb) info cuda kernels
No CUDA kernels.
(cuda-gdb)

As you can see from the output, matrixMul is generated with debug symbols, I set a breakpoint inside the kernel code and run, the debugger breaks but it does so after the end of the kernel code, no indication of thread/block/etc… and when queried about kernels, the debugger claims that there are none.

Any advice?

Looks like I missed this part in the documentation:

The following features are not supported in this release:

2. CUDA debugging or profiling tools are not supported in WSL 2. This capability will be added in a future release.

Unfortunately, not to be able to debug code is a showstopper for me.
Any ETA for when this will be added?

1 Like

nvidia driver 520+ add cuda-gdb support. I have try , it is wonderful.