Cuda-gdb/13/gdb/cuda/cuda-state.c:250: internal-error: create_module: Assertion `context' failed

I’m debugging the following program in Ubuntu-24.04 WSL:

#include <cstdio>

__global__ void kernel() {
  printf("ok\n"); //break
  printf("ok\n");
}

int main() {
  kernel<<<1, 1>>>();
  cudaDeviceSynchronize();
  return 0;
}

Gdb fails with the assertion:

$ gdb /path/to/program
NVIDIA (R) cuda-gdb 12.8
Portions Copyright (C) 2007-2024 NVIDIA Corporation
Based on GNU gdb 13.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/nd/w/a/CLionProjects/cudaTest/cmake-build-debug-wsl-cuda-gdb/cudaTest...
(cuda-gdb) b main.cu:4
Breakpoint 1 at 0x8d8a: file /home/nd/w/a/CLionProjects/cudaTest/main.cu, line 6.
(cuda-gdb) run
Starting program: /home/nd/w/a/CLionProjects/cudaTest/cmake-build-debug-wsl-cuda-gdb/cudaTest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff5fff000 (LWP 35007)]
[New Thread 0x7ffff4d6e000 (LWP 35008)]
[Detaching after fork from child process 35009]
[New Thread 0x7fffeffff000 (LWP 35018)]
[Thread 0x7fffeffff000 (LWP 35018) exited]
[New Thread 0x7fffeffff000 (LWP 35019)]
cuda-gdb/13/gdb/cuda/cuda-state.c:250: internal-error: create_module: Assertion `context' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
----- Backtrace -----
0x52954b ???
0x95ab34 ???
0x95ad58 ???
0xaf8ec1 ???
0x621ff6 ???
0x5ed474 ???
0x5edabe ???
0x49ba5f ???
0x798ba2 ???
0x9157c4 ???
0x7516b2 ???
0x7639b4 ???
0xaf98fc ???
0xaf9a05 ???
0x7ac1e6 ???
0x7ada14 ???
0x449524 ???
0x7f731acab1c9 __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7f731acab28a __libc_start_main_impl
        ../csu/libc-start.c:360
0x45133d ???
0xffffffffffffffff ???
---------------------
cuda-gdb/13/gdb/cuda/cuda-state.c:250: internal-error: create_module: Assertion `context' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

Nvidia-smi output:

$ nvidia-smi
Wed Feb 19 12:03:37 2025
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.86.17              Driver Version: 572.42         CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| 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 GTX 1650        On  |   00000000:01:00.0  On |                  N/A |
| 30%   34C    P8             N/A /   75W |    1133MiB /   4096MiB |      2%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
1 Like

Hi, @dmitry.neverov

Sorry for the late response. Did the sample run well without cuda-gdb ?

Checked: without gdb it runs without a problem.

Hi, @dmitry.neverov

I noticed your NVIDIA-SMI and driver version are not consistent. How do you set up the ENV ?
Also I have tried latest public release, CUDA Toolkit 12.9 Downloads | NVIDIA Developer can not reproduce.

Could you please explain what is inconsistent about driver version? I followed instructions in 1. NVIDIA GPU Accelerated Computing on WSL 2 — CUDA on WSL 12.9 documentation.

Cuda-12.9 still doesn’t work, but with a different error:

$ /usr/local/cuda-12.9/bin/cuda-gdb /path/to/executable
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/nd/w/a/CLionProjects/cudaTest/cmake-build-debug-wsl-cuda-gdb/cudaTest...
(cuda-gdb) b main.cu:5
Breakpoint 1 at 0x8d8a: file /home/nd/w/a/CLionProjects/cudaTest/main.cu, line 6.
(cuda-gdb) run
Starting program: /home/nd/w/a/CLionProjects/cudaTest/cmake-build-debug-wsl-cuda-gdb/cudaTest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff5fff000 (LWP 5937)]
[New Thread 0x7ffff4d6e000 (LWP 5938)]
[Detaching after fork from child process 5939]
[New Thread 0x7fffeffff000 (LWP 5948)]
[Thread 0x7fffeffff000 (LWP 5948) exited]
[New Thread 0x7fffeffff000 (LWP 5949)]
warning: Cuda API error detected: cudaLaunchKernel returned (CUresult=222)

[Thread 0x7ffff4d6e000 (LWP 5938) exited]
[Thread 0x7fffeffff000 (LWP 5949) exited]
[Thread 0x7ffff5fff000 (LWP 5937) exited]
[Inferior 1 (process 5933) exited normally]
(cuda-gdb)

Oh. Sorry. I didn’t notice you are using WSL before. That explains the driver version.

I tried on WSL, still can not repro.

Do you have below register “HKEY_LOCAL_MACHINE\SOFTWARE\NVIDIA Corporation\GPUDebugger\EnableInterface” set as (DWORD) 1 on the machine ?

Yes, “HKEY_LOCAL_MACHINE\SOFTWARE\NVIDIA Corporation\GPUDebugger\EnableInterface” is set to 1.

Windows driver version is 572.42.

Can you please upgrade the windows driver also ?
You can use CUDA Toolkit 12.9 Downloads | NVIDIA Developer, the driver version is 576.02

Thank you. Upgrading to 576.02 did help. 576.52 works as well.

You are welcome and glad to know it works now.

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