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"}, } ] }
vscode调试debug
于 2021-07-10 17:30:08 首次发布