动态库需编译成debug版本
cuda编译指令为
$(NVCC) -m64 -g -G -std=c++11 $(foreach dir, $(INCLUDE_PATH), -I$(dir)) --default-stream per-thread $(GENCODE_FLAGS) -Xcompiler -fPIC -c $< -o $@
g++ -D_DEBUG -g -DDEBUG=1 -fPIC $(foreach dir, $(INCLUDE_PATH), -I$(dir))
不能显示容器里的值参考添加链接描述和添加链接描述
博客记载了目前使用的vscode编辑器,debug程序是launch.json,c_cpp_properties.json和tasks.json的配置。
#launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/opt/zhangyong/lastest/compute_lib/rotate_detect/demo/dt_demo",
"args": ["1","hs"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [{"name": "LD_LIBRARY_PATH",
"value": "${LD_LIBRARY_PATH}:/opt/zhangyong/lastest/compute_lib/lib/gpu_lib:/opt/zhangyong/lastest/compute_lib/lib/linux_lib"}],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "enable pretty printing",
"text": "set env LD_LIBRARY_PATH=/opt/zhangyong/lastest/compute_lib/lib/gpu_lib:/opt/zhangyong/lastest/compute_lib/lib/linux_lib:/opt/zhangyong/lastest/compute_lib/model2trt_v2_d/lib",
"ignoreFailures": false
},
{
"description": "enable pretty printing",
"text": "python import sys;sys.path.insert(0, '/root/.gdb/stlprettyprinter');from libstdcxx.v6.printers import register_libstdcxx_printers;register_libstdcxx_printers(None)",
"ignoreFailures": false
}
],
"miDebuggerPath": "/usr/bin/gdb",
// "miDebuggerServerAddress": "192.168.1.147"
}
]
}
```python
#tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "nvcc",
"args":["-g","${file}","-o","${fileDirname}/${fileBasenameNoExtension}.out",
"-I", "/opt/zhangyong/lastest/compute_lib/include/cuda",
"-L", "/opt/zhangyong/lastest/compute_lib/lib/gpu_lib",
"-l", "cudart",
"-l", "cublas",
"-l", "cudnn",
"-l", "curand",
"-D_MWAITXINTRIN_H_INCLUDED"
]
}
]
}
#c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}",
"/usr/include",
"/usr/include/x86_64-linux-gnu/sys",
"/opt/zhangyong/lastest/compute_lib/include/cuda"
],
"defines": [],
"browse":{
"path":[
"/usr/include"
]
},
"compilerPath": "/opt/zhangyong/lastest/compute_lib/platform/cuda/bin",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
python
需要调试分布式版本代码时
os.environ["WORLD_SIZE"]="1"
os.environ["RANK"]="0"
os.environ["MASTER_PORT"]="12349"
os.environ["MASTER_ADDR"]="localhost"
launch.json