网上运行方法都是在命令行中使用
python -m torch.distributed.launch
进行训练,而这个语句在新版本torch中已经淘汰,因此会报错,解决方法为 把这句直接改成 torchrun就能成功运行,后面的内容是不变的
The error will disappear when you use torchrun
instead of (the deprecated?) torch.distributed.launch
. In your case python -m torch.distributed.launch --nproc_per_node=4 --master_port=27803 ...
will be replaced by torchrun --nproc_per_node=4 --master_port=27803 ...
.