1

Background: Running VSCode on Ubuntu 20.04

The following have been accomplished:

(a) Compiled and build the Cython wrapper for CUDA code (packaged as shared library .so);

(b) Python script importing said .so file runs, and can be debugged directly from cuda-gdb in terminal (thanks to this link as well as enabling the ptrace_scope), can see GPU variables and switch focus

(c) separately I have been able to set breakpoint in a different CUDA code (no wrapping, pure CUDA code linked and compiled to an executable) in both command-line cuda-gdb and VSCode's native IDE. As seen here in this youtube video

Problem: from (b) I know that the GPU debugging symbols are there, and can be picked up by cuda-gdb. But ultimately I would like to be able to debug in VSCode instead. I have tried the following 4 approaches in launch.json (as I have done so for the executable but cannot for the Cython-interfaced python script)

  1. use the command:cuda.pickProcess, and then picking the python process:
{
“name”: “CUDA C++: Attach”,
“type”: “cuda-gdb”,
“request”: “attach”,
“processId”: “${command:cuda.pickProcess}”

Result 1: nothing comes up on the Debug Console tab, no breakpoint hitting

  1. Using ps grep to find the process ID, put it directly in the processId
    {
    “name”: “CUDA C++: Attach”,
    “type”: “cuda-gdb”,
    “request”: “attach”,
    “processId”: “12345” #The Process ID = 12345
    },

Result 2: same as 1., nothing happens

3) Trying to invoke the python executable and providing the python script as argument (test.py runs the cuda code, as it has been verified with command line cuda-gdb)

{
“name”: “(gdb) Launch Python”,
“type”: “cuda-gdb”,
“request”: “launch”,
“program”: “/home/jeff/JTDev/venv/bin/python3”,
“args”:”/home/jeff/JTDev/03 Cython/JTCudaLibCython/test.py”,
“stopAtEntry”: false,
}

Result 3: cuda-gdb appears to be launched in “DEBUG CONSOLE” tab but it seems to have not done any thing (if the script + CUDA code were run, it would have output if the summation has been finished or not):

11.7 release
Portions Copyright (C) 2007-2022 NVIDIA Corporation
GNU gdb (GDB) 10.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
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:
.
Find the GDB manual and other documentation resources online at:
.

For help, type “help”.
Type “apropos word” to search for commands related to “word”.
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/x86_64-linux-gnu/libthread_db.so.1”.
[Inferior 1 (process 211846) exited with code 02]"
  1. switching the type in settings.json from ‘cuda-gdb’ to ‘cppdbg’ in the launch.json:
{
“name”: “(gdb) Launch 1123”,
“type”: “cppdbg”,
“request”: “launch”,
“program”: “/home/jeff/JTDev/venv/bin/python3”,
“args”: [
“/home/jeff/JTDev/03 Cython/CythonCUDA/test.py”
],
“stopAtEntry”: false,
“cwd”: “${workspaceFolder}”,
“externalConsole”: false,
“MIMode”: “gdb”,
“setupCommands”: [
{
“description”: “Enable pretty-printing for gdb”,
“text”: “-enable-pretty-printing”,
“ignoreFailures”: true
}
]
}

Result 4: Now it will run the python script unlike in attempt 3, and it will break at the line leaving the kernel (not where the CUDA individual thread lines). So the VSCode Can run Python script in this setting, and the CPU debug symbol can be picked up by the VSCode IDE. As seen from before, cuda-gdb proves the GPU debugging symbols is here, but somehow when invoking the cuda-gdb in “type” in launch.json, the cuda debugger is not launched correctly in VSCode for it to pick up the GPU debugging symbol and break at the device code lines.

Any help/tips are greatly appreciated.

1 Answers1

0

Make sure to compile cu file with debug symbol info.

Try using -G -g -O0 flag

sm3sher
  • 2,764
  • 1
  • 11
  • 23