grpo 多机多卡训练timeout
node1 7卡,node2 8卡,训练出现timeout
-- Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
[W228 18:45:15.738941174 socket.cpp:462] [c10d] waitForInput: poll for socket SocketImpl(fd=11, addr=[xxxxx.com]:38674, remote=[::ffff:33.148.62.162]:23456) returned 0, likely a timeout
[W228 18:45:15.741177013 socket.cpp:487] [c10d] waitForInput: socket SocketImpl(fd=11, addr=[xxxxxx.com]:38674, remote=[::ffff:33.148.62.162]:23456) timed out after 900000ms
Traceback (most recent call last):
File "/opt/conda/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/conda/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/opt/conda/lib/python3.10/site-packages/torch/distributed/run.py", line 923, in
我也是这个问题,怎么解决啊?
我也是这个问题,怎么解决啊?
不知道,官方的人目前不打算处理。已转用openrlhf去了。
Check whether the MASTER_PORT is the same and whether parameters such as MASTER_ADDR are correctly configured.
Check whether the
MASTER_PORTis the same and whether parameters such asMASTER_ADDRare correctly configured.
你好!请问一下怎么设置MASTER_ADDR?当我有4个机器,每个机器都有不同的IP。
@CQUPT-wlh set MASTER_PORT to the address of your master node.
Still have this problem as ms-swift 3.2.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv WARNING: All log messages before absl::InitializeLog() is called are written to STDERR E0000 00:00:1743068936.645910 2978755 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered to floating-point round-off errors from different computation orders. To turn them off, set the environment variable
TF_ENABLE_ONEDNN_OPTS=0. 2025-03-27 17:48:56.630822: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered WARNING: All log messages before absl::InitializeLog() is called are written to STDERR E0000 00:00:1743068936.645910 2978755 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered E0000 00:00:1743068936.650500 2978755 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered W0000 00:00:1743068936.662506 2978755 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. W0000 00:00:1743068936.662523 2978755 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. W0000 00:00:1743068936.662525 2978755 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. W0000 00:00:1743068936.662527 2978755 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once. 2025-03-27 17:48:56.666638: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. /usr/local/lib/python3.10/site-packages/xformers/ops/fmha/flash.py:211: FutureWarning:torch.library.impl_abstractwas renamed totorch.library.register_fake. Please use that instead; we will removetorch.library.impl_abstractin a future version of PyTorch. @torch.library.impl_abstract("xformers_flash::flash_fwd") /usr/local/lib/python3.10/site-packages/xformers/ops/fmha/flash.py:344: FutureWarning:torch.library.impl_abstractwas renamed totorch.library.register_fake. Please use that instead; we will removetorch.library.impl_abstractin a future version of PyTorch. @torch.library.impl_abstract("xformers_flash::flash_bwd") run sh:/usr/local/bin/python -m torch.distributed.run --nproc_per_node 7 --master_port 23461 --nnodes 2 --master_addr 10.200.101.34 /path/ms-swift/swift/cli/rlhf.py --rlhf_type grpo --model /path/public/Qwen/Qwen2.5/Qwen2.5-7B-Instruct-1M --reward_funcs accuracy format --use_vllm true --vllm_device auto --vllm_gpu_memory_utilization 0.9 --vllm_max_model_len 16384 --num_infer_workers 1 --train_type full --torch_dtype bfloat16 --dataset /path/NuminaMath_TIR --max_completion_length 8192 --num_train_epochs 10 --per_device_train_batch_size 1 --per_device_eval_batch_size 1 --learning_rate 1e-6 --gradient_accumulation_steps 14 --eval_steps 200 --save_steps 200 --save_total_limit 2 --logging_steps 5 --max_length 16384 --output_dir /path/ms-swift-8k --warmup_ratio 0.01 --dataloader_num_workers 4 --dataset_num_proc 4 --num_generations 14 --temperature 0.9 --system examples/train/grpo/prompt.txt --deepspeed zero2 --log_completions trueWARNING:main:
Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
[W327 18:04:23.284079037 socket.cpp:428] [c10d] While waitForInput, poolFD failed with (errno: 0 - Success). Traceback (most recent call last): File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.10/site-packages/torch/distributed/run.py", line 905, in
main() File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 348, in wrapper return f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/distributed/run.py", line 901, in main run(args) File "/usr/local/lib/python3.10/site-packages/torch/distributed/run.py", line 892, in run elastic_launch( File "/usr/local/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 133, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/usr/local/lib/python3.10/site-packages/torch/distributed/launcher/api.py", line 255, in launch_agent result = agent.run() File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/metrics/api.py", line 124, in wrapper result = f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/agent/server/api.py", line 680, in run result = self._invoke_run(role) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/agent/server/api.py", line 829, in _invoke_run self._initialize_workers(self._worker_group) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/metrics/api.py", line 124, in wrapper result = f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/agent/server/api.py", line 652, in _initialize_workers self._rendezvous(worker_group) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/metrics/api.py", line 124, in wrapper result = f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/agent/server/api.py", line 502, in _rendezvous workers = self._assign_worker_ranks(store, group_rank, group_world_size, spec) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/metrics/api.py", line 124, in wrapper result = f(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/distributed/elastic/agent/server/api.py", line 577, in _assign_worker_ranks role_infos_bytes = store.multi_get( torch.distributed.DistStoreError: Socket Timeout
Script:
# set -x
# NCCL Settings
# export NCCL_IB_GID_INDEX=3
# export WANDB_DISABLED=true
# export NCCL_DEBUG=WARN
# export CUDA_LAUNCH_BLOCKING=1
export NCCL_SOCKET_IFNAME=eth0
export NCCL_DEBUG=INFO
# Set VLLM
export VLLM_ATTENTION_BACKEND=XFORMERS
if [ ${MASTER_ADDR} == 'localhost' ]; then
export MASTER_ADDR=`hostname -i`
fi
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
export NNODES=2
export NODE_RNAK=${RANK}
# export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
export MASTER_ADDR=${MASTER_ADDR}
export MASTER_PORT=${MASTER_PORT}
export NPROC_PER_NODE=7
# export LOCAL_WORLD_SIZE=7
swift rlhf \
--rlhf_type grpo \
--model ${MODEL_DIR} \
--reward_funcs accuracy format \
--use_vllm true \
--vllm_device auto \
--vllm_gpu_memory_utilization 0.9 \
--vllm_max_model_len ${MAX_LENGTH:-16384} \
--num_infer_workers 1 \
--train_type full \
--torch_dtype bfloat16 \
--dataset ${DATASET_DIRS} \
--max_completion_length ${MCL:-8192} \
--num_train_epochs 10 \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--learning_rate 1e-6 \
--gradient_accumulation_steps 14 \
--eval_steps 200 \
--save_steps 200 \
--save_total_limit 2 \
--logging_steps 5 \
--max_length ${MAX_LENGTH:-16384} \
--output_dir ${OUTPUT_DIR} \
--warmup_ratio 0.01 \
--dataloader_num_workers 4 \
--dataset_num_proc 4 \
--num_generations 14 \
--temperature 0.9 \
--system 'examples/train/grpo/prompt.txt' \
--deepspeed zero2 \
--log_completions true
# --report_to swanlab \
# --swanlab_token ${SWANLAB_TOKEN} \
# --swanlab_project ${SWANLAB_PROJECT:-easy_r1} \
# --swanlab_exp_name ${SWANLAB_EXP_NAME} \
# --swanlab_mode ${SWANLAB_MODE:-cloud}
Ran on Slurm (K8S), with base docker image ubuntu22.04-cuda12.1.0-py310-torch2.4.0-tf2.16.1-1.18.1-LM from model scope, and
cd ms-swift
pip install -e . &&
pip install tf-keras &&
pip install -U accelerate &&
pip install -U lmdeploy &&
@WenhsunWu Can you check if the issue exists in vllm 0.7.3? By the way, make sure to set the same parameters on different nodes.
@WenhsunWu Can you check if the issue exists in vllm 0.7.3? By the way, make sure to set the same parameters on different nodes.
感谢,现在已经跑起来了,是一些包的版本问题,换了几个包的版本就好了。
@WenhsunWu Can you check if the issue exists in vllm 0.7.3? By the way, make sure to set the same parameters on different nodes.
感谢,现在已经跑起来了,是一些包的版本问题,换了几个包的版本就好了。
你能打印一份环境么?我看看是哪里的问题。
@WenhsunWu Can you check if the issue exists in vllm 0.7.3? By the way, make sure to set the same parameters on different nodes.
Same, still hang after Setting OMP_NUM_THREADS environment.
FYI, Single-node multi-GPU GRPO and multi-node SFT both works.
@WenhsunWu It seems that you've solved the problem. Could you share your solution for others to reference?
@hjh0119
Thanks for asking! You were right, I had resolved the earlier issue. It turned out to be a simple typo in my script: I had written NODE_RNAK instead of NODE_RANK😂 Correcting that fixed the initial problem for me.
For context, here is the Dockerfile I'm using to build the environment:
# Use the specified base image
FROM hiyouga/verl:ngc-th2.5.1-cu120-vllm0.7.3
WORKDIR /tmp
# Clone ms-swift source code
RUN git clone --depth 1 https://github.com/modelscope/ms-swift.git ms-swift-src
RUN \
# Install ms-swift from the temporary location
pip install --no-cache-dir ./ms-swift-src && \
\
# Install additional dependencies
pip install --no-cache-dir \
math_verify \
lmdeploy \
evalscope \
opencv-fixer==0.2.5 \
"deepspeed==0.14.5" \
antlr4-python3-runtime==4.13.2 && \
\
# Run the opencv-fixer command AFTER installing the package, this fix the cv2 import problem in my Env
python -c "from opencv_fixer import AutoFix; AutoFix()" && \
\
# Clean up: Remove the temporary source code directory
rm -rf ./ms-swift-src
# Reset WORKDIR to a more standard location if desired
WORKDIR /workspace
However, I've now run into a new issue during training. After about 200 steps, the process fails with an error related to the math_verify library and sympy.
The error occurs during what seems like a comparison step within math_verify. Here's the relevant part of the traceback:
WARNING:latex2sympy2_extended.math_normalization:equations is deprecated, as it handled by the parser now ... (repeated warnings) ... File "/usr/local/lib/python3.10/dist-packages/math_verify/grader.py", line 274, in sympy_solve_and_compare solved_gold = list(ordered(solve(gold, gold.free_symbols))) File "/usr/local/lib/python3.10/dist-packages/sympy/core/sorting.py", line 298, in ordered d[None].extend(seq) TypeError: 'StrictLessThan' object is not iterable
It looks like sympy.solve might be returning a StrictLessThan object in some cases, which ordered cannot iterate over.
I suspect this might be related to dependency versions. I specifically added antlr4-python3-runtime==4.13.2 to fix a previous ANTLR issue.
I would be very grateful if contributors could provide a reference to a known-stable Dockerfile or a pre-built Docker image that can be used to run this program successfully 😃
Quick note: I saw the new ModelScope image modelscope/modelscope:ubuntu22.04-cuda12.4.0-py310-torch2.5.1-1.23.1-LLM. It looks potentially suitable for GRPO training. But unfortunately I can't test it, as our k8s environment is limited to CUDA 12.3. Still looking for options compatible with CUDA 12.3 or lower.
The new image will be released soon