修改.vscode/launch.json
文件的
默认的设置是
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
}
]
修改为
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "/home/xxx/anaconda3/envs/xxx/lib/python3.8/site-packages/torch/distributed/launch.py",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
"--nproc_per_node=1",
"--nnodes=1",
"--node_rank=0", // ddp 相关的参数
"train.py", // 要运行的python文件
"--out_dir=coco_model", // python文件输入的参数
"--dataset=coco",
"--epochs=10",
],
"env": {
"CUDA_VISIBLE_DEVICES": "0, 1" //环境相关的参数在这里
},
}
]