deepspeed 訓練多機多卡報錯 ncclSystemError Last error

 

最近在搞分佈式訓練大模型,踩了兩個晚上的坑今天終於爬出來了

我們使用 2臺 8*H100

遇到過

錯誤1

10.255.19.85: ncclSystemError: System call (e.g. socket, malloc) or external library call failed or device error.
10.255.19.85: Last error:
10.255.19.85: socketStartConnect: Connect to 127.0.0.1<34273> failed : Software caused connection abort

錯誤2

10.255.19.82: torch.distributed.DistBackendError: [7] is setting up NCCL communicator and retrieving ncclUniqueId from [0] via c10d key-value store by key '0', but store->get('0') got error: Connection reset by

錯誤3

10.255.19.85: ncclInternalError: Internal check failed.
10.255.19.85: Last error:
10.255.19.85: Bootstrap : no socket interface found

 

其實這三個錯誤都是一個問題導致的,就是網卡配置的問題

這是之前的配置

hostfile

 

10.255.19.82 slots=8
10.255.19.85 slots=8

 

fine-tune.sh

 

hostfile="/data2/xinyuuliu/Baichuan2-main/fine-tune/hostfile"

export NCCL_SOCKET_IFNAME=enp194s0f0
# export MASTER_ADDR=10.255.19.82   # 主節點的IP地址
# export MASTER_PORT=29500
# --include localhost:0,1,2,3,4,5,6,7
export NCCL_DEBUG=INFO
# export NCCL_IB_TIMEOUT=22
# export NCCL_IB_GID_INDEX=3
# export NCCL_IB_TC=128
# export NCCL_IB_DISABLE=1

deepspeed --master_addr 10.255.19.82 --master_port 29500 --hostfile=$hostfile fine-tune.py  \
    --report_to "none" \
    --data_path "/data2/xinyuuliu/Baichuan2-main/fine-tune/data/全網評價總結訓練數據.json" \
    --model_name_or_path "/data1/xinyuuliu/Baichuan2-13B-Chat" \
    --output_dir "output_lora_summary" \
    --model_max_length  10000\
    --num_train_epochs 10 \
    --per_device_train_batch_size 4 \
    --gradient_accumulation_steps 1 \
    --save_strategy epoch \
    --learning_rate 2e-4 \
    --lr_scheduler_type constant \
    --adam_beta1 0.9 \
    --adam_beta2 0.98 \
    --adam_epsilon 1e-8 \
    --max_grad_norm 1.0 \
    --weight_decay 1e-4 \
    --warmup_ratio 0.0 \
    --logging_steps 1 \
    --gradient_checkpointing True \
    --deepspeed ds_config.json \
    --bf16 True \
    --tf32 True \
    --use_lora True \
    # --load_lora_path /data2/xinyuuliu/Baichuan2-main/fine-tune/output_lora4_1_1/checkpoint-7516
    # --use_NEFT True
    # --use_frozen True

 #"/data2/xinyuuliu/baichuan2_7B"

 

 

修改後之後的配置

問題主要出現在 NCCL_SOCKET_IFNAME 這個環境變量,這個環境變量會被攜帶到其他機器上,但是網卡的名稱是不一樣的,尤其我的兩臺機器包含很多的網卡,因此,我們配置的時候需要把那些沒用的虛擬網卡屏蔽掉,只留下需要的

解決方法,這個要根據實際情況來改,英偉達官方寫法如下,屏蔽顯卡用^開頭

export NCCL_SOCKET_IFNAME=^br-c485a8390817,docker0,eno2,ens6f0,ens6f1,enx46a838614d5f,lo,veth23d7383,br-dcd3e4ec14e7,enp194s0f1,ens6f0,ens6f1,enxe278666d5a52,veth110d0b7,veth215ea4e,veth3203d6b,veth87c3cbf,vethec6fc79,virbr0

 我的網卡太多了,之前一直以爲環境變量在 /etc/profile 下配置各自的就行,

然後再source /etc/profile,結果發現不對,從機也都指向了主機的網卡,沒辦法建立socket


 

 

hostfile="/data2/xinyuuliu/Baichuan2-main/fine-tune/hostfile"

export NCCL_SOCKET_IFNAME=^br-c485a8390817,docker0,eno2,ens6f0,ens6f1,enx46a838614d5f,lo,veth23d7383,br-dcd3e4ec14e7,enp194s0f1,ens6f0,ens6f1,enxe278666d5a52,veth110d0b7,veth215ea4e,veth3203d6b,veth87c3cbf,vethec6fc79,virbr0
# export NCCL_SOCKET_IFNAME=enp194s0f0
# export MASTER_ADDR=10.255.19.82   # 主節點的IP地址
# export MASTER_PORT=29500
# --include localhost:0,1,2,3,4,5,6,7
export NCCL_DEBUG=INFO
# export NCCL_IB_TIMEOUT=22
# export NCCL_IB_GID_INDEX=3
# export NCCL_IB_TC=128
# export NCCL_IB_DISABLE=1

deepspeed --master_addr 10.255.19.82 --master_port 29500 --hostfile=$hostfile fine-tune.py  \
    --report_to "none" \
    --data_path "/data2/xinyuuliu/Baichuan2-main/fine-tune/data/全網評價總結訓練數據.json" \
    --model_name_or_path "/data1/xinyuuliu/Baichuan2-13B-Chat" \
    --output_dir "output_lora_summary" \
    --model_max_length  10000\
    --num_train_epochs 10 \
    --per_device_train_batch_size 4 \
    --gradient_accumulation_steps 1 \
    --save_strategy epoch \
    --learning_rate 2e-4 \
    --lr_scheduler_type constant \
    --adam_beta1 0.9 \
    --adam_beta2 0.98 \
    --adam_epsilon 1e-8 \
    --max_grad_norm 1.0 \
    --weight_decay 1e-4 \
    --warmup_ratio 0.0 \
    --logging_steps 1 \
    --gradient_checkpointing True \
    --deepspeed ds_config.json \
    --bf16 True \
    --tf32 True \
    --use_lora True \
    # --load_lora_path /data2/xinyuuliu/Baichuan2-main/fine-tune/output_lora4_1_1/checkpoint-7516
    # --use_NEFT True
    # --use_frozen True

 #"/data2/xinyuuliu/baichuan2_7B"

修改後成功跑起16*H100,爽歪歪

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章