vscode调试debug

F5之后,选择

点了之后依然选

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: run.py",
            "type": "python",
            "request": "launch",
            "program": "run.py",
            "console": "integratedTerminal",
            "args": [
                "--data_root", "datasets/ct80",
                "--mask_root", "datasets/mask/testing_mask_dataset",
                "--model_path", "pretrainedModel/checkpoint_paris.pth",
                "--batch_size", "6",
                "--num_iters", "900000",
                "--tps_inputsize", "32","64","128",
                ]

            // "env": {"CUDA_VISIBLE_DEVICES": "9"}
        }
        {
            "name": "Python: main_font.py",
            "type": "python",
            "request": "launch",
            "program": "main_font.py",
            "console": "integratedTerminal",
            "args": [
                "--dataset", "CIFAR10",
                ]
        }
    ]
}

注意这里第一项"--data_root"这里面如果多一个空格"--data_root "都会报错

想让debug可以用相对路径

加个cwd,将调试器的当前工作目录指定为当前文件所在的目录

  • ${fileDirname} - the current opened file's dirname
  • ${workspaceFolder} - the path of the folder opened in VS Code
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "cwd": "${fileDirname}"
        }
    ]
}

加上"cwd": "${fileDirname}"的话,像

"args": [

                "my_crellov2.py",

                "../work_dirs/Deformable_DETR-Crellov2/latest.pth",

               ]

这个../workdirs,  这个../是相对于你按F5的时候打开的那个文件所在的路径来说的

vscode调试torch.distributed.launch

采用单卡调试,也就是说我们的调试要达到一下命令的效果

python -m torch.distributed.launch --nproc_per_node 1 train.py

下面是修改后的文件,其中program是我们要运行的文件,就是launch.py,然后-m参数忽略即可,args重视我们后续的参数,有–nproc_per_node 1以及train.py

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "/home/wangyh/anaconda3/envs/torch/lib/python3.6/site-packages/torch/distributed/launch.py",
            "console": "integratedTerminal",
            "args": [
                "--nproc_per_node=1",
                "train.py",
            ],
            "env": {"CUDA_VISIBLE_DEVICES":"0"},
        }
    ]
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值