Huggingface - 5.Transformer实验
1.全量参数微调
先设计一下要跑哪几个实验:
- 使用 accelerate 库在单卡上启动 transformers 库中提供的训练脚本;
- 使用 accelerate 库在双卡(数据并行)上启动 transformers 库中提供的训练脚本;
- 使用 deepspeed 库在单卡(ZeRO3)上启动 transformers 库中提供的训练脚本;
- 使用 deepspeed 库在双卡(ZeRO3)上启动 transformers 库中提供的训练脚本;
1.1 Accelerate 单卡
accelerate 的配置:
1 | compute_environment: LOCAL_MACHINE |
启动命令:
1 | accelerate launch \ |
训练日志:
1 | [INFO|trainer.py:1779] 2023-05-22 00:42:36,114 >> ***** Running training ***** |
显存使用情况:
1 | + |
1.2 Accelerate 双卡
accelerate 的配置:
1 | compute_environment: LOCAL_MACHINE |
启动命令:
1 | accelerate launch \ |
训练日志:
1 | [INFO|trainer.py:1779] 2023-05-22 00:56:37,438 >> ***** Running training ***** |
显存使用情况:
1 | + |
1.3 DeepSpeed 单卡
deepspeed 的配置:
1 | { |
启动命令:
1 | deepspeed --num_gpus=1 \ |
训练日志:
1 | [INFO|trainer.py:1779] 2023-05-22 00:26:45,120 >> ***** Running training ***** |
显存使用情况:
1 | + |
1.4 DeepSpeed 双卡
优化器分片+梯度分片+参数分片;
deepspeed 的配置:
1 | { |
启动命令:
1 | deepspeed --num_gpus=2 \ |
训练日志:
1 | [INFO|trainer.py:1779] 2023-05-22 00:13:55,728 >> ***** Running training ***** |
显存使用情况:
1 | + |
Comment