docs/version2.x/ppocr/blog/distributed_training.md
paddle.distributed.launch的接口启动训练任务即可。下面为运行代码示例。python3 -m paddle.distributed.launch \
--log_dir=./log/ \
--gpus "0,1,2,3,4,5,6,7" \
tools/train.py \
-c configs/rec/rec_mv3_none_bilstm_ctc.yml
--ips的参数,该参数表示需要参与分布式训练的机器的ip列表,不同机器的ip用逗号隔开。下面为运行代码示例。ip_list="192.168.0.1,192.168.0.2"
python3 -m paddle.distributed.launch \
--log_dir=./log/ \
--ips="${ip_list}" \
--gpus="0,1,2,3,4,5,6,7" \
tools/train.py \
-c configs/rec/rec_mv3_none_bilstm_ctc.yml
注:
ifconfig或者ipconfig查看。ip_list中的第一台机器的第一块设备是trainer0,以此类推。在2机8卡P40的机器上进行模型训练,不同模型的精度、训练耗时、多机加速比情况如下所示。
| 模型 | 配置 | 数据集 | 单机8卡耗时/精度 | 2机8卡耗时/精度 | 加速比 |
|---|---|---|---|---|---|
| CRNN | rec_chinese_lite_train_v2.0.yml | 26W中文数据集 | 2.50d/66.7% | 1.67d/67.0% | 1.5 |
在3机8卡V100的机器上进行模型训练,不同模型的精度、训练耗时、多机加速比情况如下所示。
| 模型 | 配置 | 数据集 | 单机8卡耗时/精度 | 3机8卡耗时/精度 | 加速比 |
|---|---|---|---|---|---|
| SLANet | SLANet.yml | PubTabNet | 49.8h/76.2% | 19.75h/74.77% | 2.52 |
注意:这里3机8卡训练时,单卡batch size相比于单机8卡不变,学习率乘以2 (默认乘以3的话,精度仅有73.42%)
在4机8卡V100的机器上进行模型训练,不同模型的精度、训练耗时、多机加速比情况如下所示。
| 模型 | 配置 | 数据集 | 单机8卡耗时/精度 | 4机8卡耗时/精度 | 加速比 |
|---|---|---|---|---|---|
| SVTR | PP-OCRv3_mobile_rec_distillation.yml | PP-OCRv3_rec data | 10d/- | 2.84d/74.0% | 3.5 |
注意: 在训练的GPU卡数过多时,精度会稍微有所损失(1%左右),此时可以尝试通过添加warmup或者适当增加迭代轮数来弥补精度损失。