PyTorch distributed training stalls until rank 0 gives up on the other ranks
Your error
torch.distributed.DistStoreError: Timed out after 61 seconds waiting for clients. 1/2 clients joined.1 more line it can showFix it fast
Most common cause, 1 of 3Fewer processes were started than the world size
Let torchrun start one process per GPU and set RANK, WORLD_SIZE, MASTER_ADDR and MASTER_PORT for each.
torchrun --standalone --nnodes=1 --nproc-per-node=2 train.py
# train.py
import os, torch, torch.distributed as dist
dist.init_process_group(backend="nccl")
torch.cuda.set_device(int(os.environ["LOCAL_RANK"]))Short answer
DistStoreError: Timed out after N seconds waiting for clients. 1/2 clients joined means rank 0 started the TCPStore and the other ranks never connected before the timeout. Check three things: every process was launched (use torchrun), the other node can reach MASTER_ADDR:MASTER_PORT, and no short init_process_group timeout ran out first. PyTorch 2.15.
Which cause do you have?
Count the Python processes of the job on every machine and compare with the world size in the message. Fewer processes than the second number in N/M is cause 1; the right count on two nodes is cause 2; a seconds value just above the timeout your code passes is cause 3.
pgrep -af "train.py"
echo "WORLD_SIZE=$WORLD_SIZE MASTER_ADDR=$MASTER_ADDR MASTER_PORT=$MASTER_PORT"Then find the line you see in this list and open its fix:
- 1Fewer processes were started than the world size
One machine, the job was started with python train.py, and the code passes world_size=2 or WORLD_SIZE=2 is exported - 2The other node cannot reach rank 0's address and port
Two or more machines, every node runs its processes, and the non-zero nodes stall or report connection timeouts - 3A short init_process_group timeout ran out before slow ranks started
The seconds in the message sit just above a timeout your code passes, for example 61 after timedelta(seconds=60)
What does the error look like?
torch.distributed.DistStoreError: Timed out after 61 seconds waiting for clients. 1/2 clients joined.DistStoreError: Timed out after ... seconds waiting for clients. .../... clients joined.
Cause 1 of 3
Fewer processes were started than the world size
You seeOne machine, the job was started with python train.py, and the code passes world_size=2 or WORLD_SIZE=2 is exported
Check
The TCPStore on rank 0 waits until world_size clients join, and the message counts how many did. With 1/2, rank 0 joined alone because nothing else was ever launched; init_process_group does not start the other ranks for you.
grep -nE "init_process_group|world_size|rank=" train.pyFix
Let torchrun start one process per GPU and set RANK, WORLD_SIZE, MASTER_ADDR and MASTER_PORT for each. Inside the script call init_process_group with only the backend, and read LOCAL_RANK for the device.
torchrun --standalone --nnodes=1 --nproc-per-node=2 train.py
# train.py
import os, torch, torch.distributed as dist
dist.init_process_group(backend="nccl")
torch.cuda.set_device(int(os.environ["LOCAL_RANK"]))Verify
While the job runs, pgrep lists two worker processes, and both get past init_process_group.
pgrep -af train.pyConfirmed by docs.pytorch.org
Cause 2 of 3
The other node cannot reach rank 0's address and port
You seeTwo or more machines, every node runs its processes, and the non-zero nodes stall or report connection timeouts
Check
MASTER_ADDR names the host that runs rank 0 and MASTER_PORT the port where it hosts the TCP store; torchrun fills both in, and env:// setups set them by hand. If the other node gets localhost, a name it cannot resolve, an address it cannot route to, or a port blocked by a firewall, its ranks never join.
nc -zv "$MASTER_ADDR" "$MASTER_PORT"Fix
Make the rank 0 host name or address resolvable and reachable from every node, open the store port between the nodes, and start all nodes with identical rendezvous settings.
# on every node, same endpoint and job id
torchrun --nnodes=2 --nproc-per-node=8 \
--rdzv-id=job42 --rdzv-backend=c10d --rdzv-endpoint=10.0.0.5:29400 \
train.pyVerify
nc reports the port as open from the other node while rank 0 waits, and every rank gets past init_process_group.
nc -zv 10.0.0.5 29400Confirmed by docs.pytorch.org
Cause 3 of 3
A short init_process_group timeout ran out before slow ranks started
You seeThe seconds in the message sit just above a timeout your code passes, for example 61 after timedelta(seconds=60)
Check
init_process_group hands its timeout to the env:// rendezvous, which builds the TCPStore with it, so the same value limits how long rank 0 waits for clients. Ranks that load data, download weights or wait for a container to start before calling init_process_group can miss a short window.
grep -n "timeout=" train.pyFix
Call init_process_group early, before heavy per-rank work, and drop the custom timeout or raise it to cover the slowest start. The documented default is 10 minutes for NCCL and 30 for other backends.
from datetime import timedelta
import torch.distributed as dist
dist.init_process_group(backend="nccl", timeout=timedelta(minutes=10))Verify
All ranks join on a cold start, and the job reaches its first training step.
torchrun --standalone --nnodes=1 --nproc-per-node=2 train.pyConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Start distributed jobs only through torchrun or your scheduler's launcher, never with bare python plus a hard-coded world size.
- Keep the rendezvous address and port in one job config that every node reads, and test the port with nc before a long run.
- Put init_process_group at the top of main, ahead of data loading and model downloads.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.