vscode分布式训练debug
使用多个gpu训练神经网络是,如何配置launch文件来debug是必不可少的。平常分布式训练时,我们一般会写一个shell脚本来配置训练参数,通过torch.distributed.launch来启动分布式训练。
#!/bin/bash
export CUDA_VISIBLE_DEVICES=4,5,6,7
export NCCL_P2P_DISABLE=0
python -m torch.distributed.launch --nproc_per_node=8 \
--master_port=18119 --nnodes=1 --node_rank=0 \
--master_addr=127.0.0.1 /home/feifei/project/yolov3/train.py \
--epoch=100 \
--batch_size=4 \
debug中使用分布式训练需要找到torch分布式包中的launch.py文件,将launch.json文件中的"program"修改为launch.py的路径。其他参数添加到“args”中。
参考链接:https://www.cxyzjd.com/article/qianbin3200896/108182504