ms-swift
ms-swift copied to clipboard
同参数情况下,单卡正常运行,多卡DDP显存OOM
Describe the bug
同参数情况下微调,单卡正常运行,多卡OOM。
单卡微调sh:
CUDA_VISIBLE_DEVICES=0 swift sft \
--dtype bf16 \
--template_type AUTO \
--model_type llama3-8b-instruct \
--model_id_or_path /... \
--dataset /... \
--val_dataset /... \
--output_dir /... \
--sft_type "full" \
--learning_rate 1e-5 \
--weight_decay 0.1 \
--max_grad_norm 0.5 \
--warmup_ratio 0.03 \
--batch_size 2 \
--gradient_accumulation_steps 16 \
--max_length 4096 \
--num_train_epochs 3 \
--save_strategy "epoch" \
--save_total_limit 3 \
两卡微调sh:
CUDA_VISIBLE_DEVICES=0,1 \
NPROC_PER_NODE=2 \
swift sft \
--dtype bf16 \
--template_type AUTO \
--model_type llama3-8b-instruct \
--model_id_or_path /... \
--dataset /... \
--val_dataset /... \
--output_dir /... \
--sft_type "full" \
--learning_rate 1e-5 \
--weight_decay 0.1 \
--max_grad_norm 0.5 \
--warmup_ratio 0.03 \
--batch_size 1 \
--gradient_accumulation_steps 16 \
--max_length 4096 \
--num_train_epochs 3 \
--save_strategy "epoch" \
--save_total_limit 3 \
即便加上了 --deepspeed 'default-zero2' 依旧爆显存。
按理说单卡batchsize为2不爆显存,那么多卡ddp场景batchsize=1也不会爆,很奇怪的问题
hardware and system info
CUDA 11.8 GPU:A800, 80G torch 2.4.0 Linux
补充一些额外信息: 用上述单卡微调sh,同数据集耗时1h45min:
CUDA_VISIBLE_DEVICES=0 swift sft \
--dtype bf16 \
--template_type AUTO \
--model_type llama3-8b-instruct \
--model_id_or_path /... \
--dataset /... \
--val_dataset /... \
--output_dir /... \
--sft_type "full" \
--learning_rate 1e-5 \
--weight_decay 0.1 \
--max_grad_norm 0.5 \
--warmup_ratio 0.03 \
--batch_size 2 \
--gradient_accumulation_steps 16 \
--max_length 4096 \
--num_train_epochs 3 \
--save_strategy "epoch" \
--save_total_limit 3 \
我更改成双卡微调加上后zero3后,同一个数据集预计耗时20h
CUDA_VISIBLE_DEVICES=0,1 \
NPROC_PER_NODE=2 \
swift sft \
--dtype bf16 \
--template_type AUTO \
--model_type llama3-8b-instruct \
--model_id_or_path /... \
--dataset /... \
--val_dataset /... \
--output_dir /... \
--sft_type "full" \
--learning_rate 1e-5 \
--weight_decay 0.1 \
--max_grad_norm 0.5 \
--warmup_ratio 0.03 \
--batch_size 1 \
--gradient_accumulation_steps 16 \
--max_length 4096 \
--num_train_epochs 3 \
--save_strategy "epoch" \
--save_total_limit 3 \
--deepspeed 'default-zero3'
或许为服务器问题,正在排查,暂时close