在进行深度学习视觉分割代码的复现时,遇到多次如下的分布式运行代码
python -m torch.distributed.run --nproc_per_node=2 train_final_voc.py --data_folder [../VOC2012]
由于使用的单卡机器,该指令无法运行
尝试了许多方法之后,得到解决方案
在vscode的launch.json中做出如下修改:
{
"configurations": [
{
"name": "Python: distribute",
"type": "debugpy",
"request": "launch",
"program": "/home/anaconda3/envs/dupl/lib/python3.9/site-packages/torch/distributed/run.py",//可执行文件路径
"console": "integratedTerminal",
"args": [
"--nproc_per_node=1",
"train_final_voc.py",
//"--model",
"--data_folder",
"/home/DuPL/datasets/VOCdevkit/VOC2012"
],
"cwd": "/home/DuPL",
"env": {"CUDA_VISIBLE_DEVICES":"0"},
}
]
}