GPU多卡训练torch模型

用命令即可:

python3 -m torch.distributed.launch --master_port 10001 --nproc_per_node 8 train.py

其中设置master_port是为了避免端口已被其他进程占用而报错,若报错可设置一个新端口号为master_port

或者

使用Accelerator: https://huggingface.co/docs/transformers/v4.21.2/en/accelerate

 

posted @ 2022-09-01 18:08  morein2008  阅读(143)  评论(0编辑  收藏  举报