VSCode无法调试Cython包装的CUDA代码(但CLI CUDA -gdb可以)



背景:在Ubuntu 20.04上运行VSCode

以下已经完成:

(a)编译并构建用于CUDA代码的Cython包装器(打包为共享库.so);

(b)导入。so文件的Python脚本可以运行,并且可以在终端中直接从cuda-gdb中进行调试(感谢这个链接以及启用ptrace_scope),可以看到GPU变量并切换焦点

(c)单独地,我已经能够在命令行CUDA -gdb和VSCode的本地IDE中设置不同CUDA代码中的断点(没有包装,纯CUDA代码链接并编译为可执行文件)。这段youtube视频

问题:从(b)我知道GPU调试符号在那里,可以通过cuda-gdb拾取。但最终我希望能够在VSCode中进行调试。我在发行过程中尝试了以下4种方法。json(我已经为可执行文件这样做了,但不能为python接口的python脚本)

  1. 使用命令:cuda。然后选择python进程:
{
“name”: “CUDA C++: Attach”,
“type”: “cuda-gdb”,
“request”: “attach”,
“processId”: “${command:cuda.pickProcess}”

结果1:Debug Console选项卡上没有任何显示,没有断点击中

  1. 使用ps grep查找进程ID,将其直接放在processId
{
“name”: “CUDA C++: Attach”,
“type”: “cuda-gdb”,
“request”: “attach”,
“processId”: “12345” #The Process ID = 12345
},

结果2:与1相同。,什么也没发生

3)试图调用python可执行文件并提供python脚本作为参数(test.py运行cuda代码,因为它已通过命令行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,
}

结果3:CUDA -gdb似乎在"DEBUG CONSOLE"选项卡中启动,但它似乎没有做任何事情(如果脚本+ CUDA代码运行,它将有输出,如果求和已完成与否):

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. 在设置中切换类型。从' cuda-gdb '到' cppdbg '在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
}
]
}

结果4:现在它将运行python脚本,不像在尝试3中,它将在离开内核的行(不是CUDA单个线程行)处中断。所以VSCode可以在这个设置中运行Python脚本,并且CPU调试符号可以被VSCode IDE拾取。如前所述,cuda-gdb证明GPU调试符号在这里,但不知何故在启动时调用"type"中的cuda-gdb。在VSCode中,cuda调试器没有正确启动,因为它会拾取GPU调试符号并在设备代码行处中断。

任何帮助/提示都非常感谢。

一定要编译带有调试符号info的cu文件

尝试使用-G -g -O0标志

最新更新