vscode debug cuda c++ python配置

动态库需编译成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

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小涵涵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值