# How do you run multi-node training across GPU machines?

> Run one torchrun per machine against a shared rendezvous, check the network math first, and debug hangs with the right flags. Tested commands inside.

Source: https://www.nodus-compute.ai/blog/multi-node-training-across-machines/
Build revision: 5442576f423981bd1fd28deffa0ad2b0445493e4

Multi-node training means starting one `torchrun` on every machine, all pointed at the same rendezvous address, so their processes form one group and NCCL averages gradients over the network between them. On Nodus, `--nodes 2 --launcher torchrun` does that wiring: it acquires the machines, checks they connect and sets `MASTER_ADDR`, `NODE_RANK` and the torchrun variables (multi-node is in Beta, with an API ceiling of 8 machines). It only pays when the network can move a step’s gradients in about the time the backward pass takes.

This post covers what our [multi-GPU training guide](https://www.nodus-compute.ai/blog/multi-gpu-training-pytorch/) skips: what must work between machines, how much data crosses the wire, and what failures look like in our own test.

## What has to work between the machines?

Two separate connections have to succeed. The first is the rendezvous: every machine’s torchrun agent contacts one store, learns the world size and gets its node rank. The second is the process group: the training processes open their own connections, and NCCL then carries every all-reduce over them.

The [torchrun docs](https://docs.pytorch.org/docs/2.15/elastic/run.html) describe two ways to rendezvous. With `--rdzv-backend c10d --rdzv-endpoint host:port`, one machine hosts a store, by default on port 29400, and torchrun assigns node ranks itself. With the static backend, you pass `--node-rank`, `--master-addr` and `--master-port` (default 29500) to every machine by hand.

The [PyTorch distributed docs](https://docs.pytorch.org/docs/2.15/distributed.html) say NCCL and Gloo pick a network interface automatically, and you override a wrong guess with `NCCL_SOCKET_IFNAME` or `GLOO_SOCKET_IFNAME`. In our run, the process group used a random port (39697), not the rendezvous port, so the firewall between machines must allow more than 29400.

## What does the launch command look like?

Run the same command on every machine. This is the pattern from the torchrun docs for two machines with 8 GPUs each:

Terminal window

```sh
torchrun --nnodes 2 --nproc-per-node 8 \
  --rdzv-backend c10d --rdzv-endpoint $HOST_NODE_ADDR --rdzv-id $JOB_ID \
  train.py
```

We tested this shape on one 8-core CPU box with PyTorch 2.15, starting two torchrun agents on localhost as two “nodes” with 2 processes each and the Gloo backend. The script ran a tiny DDP model for 20 steps:

Terminal window

```sh
torchrun --nnodes 2 --nproc-per-node 2 --rdzv-backend c10d \
  --rdzv-endpoint localhost:29400 --rdzv-id smoke ddp_smoke.py
```

Rank 0 printed `all_reduce sum=4 (expect 4); weights identical on all ranks=True`, and the run finished in 9.5 seconds. This was a CPU, Gloo and localhost test of the launch logic. It is not a GPU or network benchmark.

## How much data crosses the network each step?

With DDP, a ring all-reduce makes every GPU send and receive about 2(N-1)/N times the gradient size per step, where N is the total GPU count. That factor comes from the [NCCL tests performance notes](https://github.com/NVIDIA/nccl-tests/blob/master/doc/PERFORMANCE.md). In a ring spread over two machines, each machine’s network ports carry about the same amount.

Take Qwen2.5-3B, which has [3.09B parameters](https://huggingface.co/Qwen/Qwen2.5-3B). Its bf16 gradients are 3.09B x 2 bytes = 6.18 GB. On 2 machines with 8 GPUs each, N = 16, so each step moves 6.18 x 2 x 15 / 16 = 11.59 GB per machine.

Compute time needs an assumption. Training costs about 6 FLOPs per parameter per token ([Kaplan et al.](https://arxiv.org/abs/2001.08361)), with the backward pass about two thirds of it. At 32,768 tokens per GPU per step, that is 6 x 3.09B x 32,768 = 6.08 x 10^14 FLOPs. If each GPU sustains an illustrative 400 TFLOP/s, a step computes for 1.52 s, of which the backward pass is 1.01 s.

Network time is 11.59 GB divided by each machine’s link speed. The speeds below are illustrative, not measurements of any provider:

|Link per machine|Network time per step|Efficiency, no overlap|10 h job on 2 machines|Cost|
|-|-|-|-|-|
|25 Gb/s|3.708 s|29.1%|17.2 h|$715.81|
|100 Gb/s|0.927 s|62.1%|8.1 h|$334.95|
|400 Gb/s|0.232 s|86.8%|5.8 h|$239.74|
|3,200 Gb/s|0.029 s|98.1%|5.1 h|$211.97|

Efficiency is 1.52 / (1.52 + network time), the worst case where nothing overlaps. Re-check one row: 11.59 GB / 12.5 GB/s = 0.927 s, and 1.52 / 2.45 = 62.1%.

![Network time per step to all-reduce Qwen2.5-3B bf16 gradients over 16 GPUs on 2 machines: 3.708 s at 25 Gb/s, 0.927 s at 100 Gb/s, 0.232 s at 400 Gb/s and 0.029 s at 3,200 Gb/s, against 1.52 s of compute.](https://www.nodus-compute.ai/blog-charts/multi-node-training-across-machines/network-time.svg) *At 25 Gb/s per machine, moving the gradients takes more than twice as long as computing them.*

## When does a second machine pay for itself?

Go multi-node when your network time per step is smaller than your backward pass, and treat the second machine as buying time rather than saving money. DDP overlaps all-reduce with the backward pass, as the [DDP design notes](https://docs.pytorch.org/docs/2.15/notes/ddp.html) explain, so network time under 1.01 s can be partly hidden. Network time above the full 1.52 s step cannot.

Price it with a job that takes 10 hours on one 8 x H100 machine. NVIDIA H100s are listed at $2.60/hr on the [Nodus pricing page](https://www.nodus-compute.ai/pricing/), so that is 80 GPU-hours, or $208.00. On two machines, wall-clock is 10 / (2 x efficiency) hours and cost is 16 x $2.60 x those hours, as in the table above.

We treat one machine’s NVLink sync as free, which flatters the single-machine case slightly. Prices checked November 27, 2026.

![Cost of a job that takes 10 hours on one 8 x H100 machine at $2.60 per GPU-hour: $208.00 on one machine, and on two machines $715.81 at 25 Gb/s, $334.95 at 100 Gb/s, $239.74 at 400 Gb/s and $211.97 at 3,200 Gb/s, assuming no overlap.](https://www.nodus-compute.ai/blog-charts/multi-node-training-across-machines/cost-by-link.svg) *At 25 Gb/s the second machine makes the job slower and 3.4 times more expensive.*

The decision rule: compute 2(N-1)/N x gradient bytes / link speed for your model. If it is under your backward time, test two machines.

If it is over your whole step time, buy a bigger single machine. Sharding with FSDP does not escape the math: it moves about 1.5 times as much data as DDP, according to the [ZeRO paper](https://arxiv.org/abs/1910.02054). Our [FSDP vs DDP comparison](https://www.nodus-compute.ai/blog/fsdp-vs-ddp/) covers that choice.

## Why does a multi-node job hang, and how do you debug it?

In our test, every failure except a crash looked like a hang first and an error later. We reproduced five on the same localhost setup, shortening the timeouts so each failed fast: `--rdzv-conf join_timeout=30` for the rendezvous, and a 30 s process group timeout.

|What we broke|What happened|Time to failure|
|-|-|-|
|Started only one of two nodes|`RendezvousTimeoutError`|32.3 s|
|Node A said `--nnodes 2`, node B said `--nnodes 3`|No mismatch error. A timed out; B got `RendezvousConnectionError`|32.2 s|
|Node B pointed at port 29401|Each node hosted its own store. Both got `RendezvousTimeoutError`|32.1 s|
|One rank slept before the first all-reduce|`Timed out waiting 30000ms for recv operation to complete`|37.2 s|
|One rank exited with code 3|Peers got `Connection closed by peer`|7.2 s|

Times are for the slower node. The wrong-port result is specific to localhost, where each node can host a store; we did not test it across real machines.

![Time to failure in our localhost torchrun test with shortened timeouts: missing node 32.3 s, mismatched nnodes 32.2 s, wrong rendezvous port 32.1 s, stalled rank 37.2 s, crashed rank 7.2 s.](https://www.nodus-compute.ai/blog-charts/multi-node-training-across-machines/time-to-failure.svg) *With default timeouts, the rendezvous and stall cases would take 10 minutes or more to surface.*

Defaults are much longer. PyTorch 2.15’s c10d rendezvous waits 600 s to join, and the process group timeout is 10 minutes for NCCL and 30 minutes for other backends. A mismatched `--nnodes` gives no hint: it looks exactly like a missing machine.

Read every node’s log. In the crash test, node A’s summary named its own rank 1 as the “root cause” with exit code 1. The real crash, exit code 3 on rank 3, appeared only in node B’s log.

When it is not obvious, turn on logging in this order. `NCCL_DEBUG=INFO` prints NCCL’s debug information, including how it initialized, and [NCCL’s environment variable docs](https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/env.html) list `NCCL_DEBUG_SUBSYS` to narrow it. `TORCH_DISTRIBUTED_DEBUG=DETAIL` with `TORCH_CPP_LOG_LEVEL=INFO` adds checks that every rank calls the same collectives.

## How do you run multi-node training on Nodus?

Nodus replaces the per-machine commands with one. This smoke test is from the [Nodus multi-node guide](https://www.nodus-compute.ai/docs/guides/multi-node/):

Terminal window

```sh
nodus run --name torchrun-2-node --gpu H100 --nodes 2 --launcher torchrun --max-cost 2.00 -- torchrun train.py
```

`torchrun` needs no flags here. Nodus sets `MASTER_ADDR`, `MASTER_PORT` (29500), `NODE_RANK` and the `PET_*` variables torchrun reads, and keeps your own `NCCL_*` settings except the few the network path decides. It starts your command only after every machine passes a connectivity check. Assembly waits up to 15 minutes by default, then retries twice before failing with `GangAssemblyTimeout`.

The guide is specific about Beta limits. The API ceiling is 8 machines, and every machine gets the same GPU count. Members on different providers that connect over public addresses send gradients and rendezvous traffic unencrypted, so keep the default `network: Colocated` for sensitive data. A two-host DDP result does not qualify cross-host FSDP or several GPUs per host across hosts.

If a machine is lost, Nodus stops every rank, replaces only the lost machine and restarts all ranks from the latest checkpoint in `$NODUS_CHECKPOINT_DIR`. Your script must save and load there, which our [checkpoint guide](https://www.nodus-compute.ai/blog/save-and-resume-pytorch-checkpoints/) shows.

## FAQ

### Do I need InfiniBand for multi-node training?

No. NCCL falls back to IP sockets when InfiniBand is unavailable, and `NCCL_IB_DISABLE=1` forces that fallback. The table above shows the cost: at 25 Gb/s, a 3B model spends more time syncing than computing.

### Can torchrun add or remove machines during a run?

Yes, if you pass a range such as `--nnodes 1:4` with the c10d backend; the torchrun docs call this elastic mode. Your script has to cope with a changing world size. On Nodus, the world size stays fixed across restarts.

### Why did training start, then stall at the first step?

The rendezvous worked but the process group or NCCL connections did not. Check that the ports between machines are open, not only the rendezvous port, and that `NCCL_SOCKET_IFNAME` points at the interface the machines share.

### Should every machine have the same number of GPUs?

Plan for it. Every step finishes at the pace of the slowest rank, so a mismatched machine leaves the others waiting at each all-reduce. Nodus gives every member the same GPU count.
