Can Two Machines with 16 GPUs Train a 100B-Parameter Model? Calculate Memory First, Then Troubleshoot
This article estimates whether a 100-billion-parameter model can be trained on two servers with 16 GPUs (64GB each). The answer is yes, under three conditions: optimizer states offloaded to host memory, roughly 1TB of RAM per host, and full activation recomputation. All figures are estimates based on stated assumptions, not measurements. The article walks through model-state memory, activation memory, cross-machine communication, the cost of optimizer offloading, a stability troubleshooting checklist, fallback options, and limitations of the analysis.
1. Conclusion and Calculation Basis
Under the estimates below, a 100B-parameter model can fit on two machines with 16 GPUs, but three conditions must hold simultaneously: optimizer states are offloaded to host memory, each host has about 1TB of RAM, and activations use full recomputation. These numbers are estimates, not measurements. Bandwidth, compute utilization, and offloading overhead must all be replaced with measured values from your own cluster. This article does not cite unverified third-party training data.
The assumptions are as follows.
| Item | Value | Notes |
|---|---|---|
| Model size | ~100B parameters, hidden size 12288, 56 layers | 12 × layers × hidden² ≈ 1.01×10¹¹, consistent with the nominal parameter count |
| Attention heads | 96 (assumed) | Head dimension 128, used only for activation estimates |
| Precision | FP16 weights and gradients; FP32 master weights and Adam states | Mixed-precision Adam, 16 bytes per parameter |
| Sequence and micro-batch | Sequence length 4096, micro-batch size 1 | Kept from the original setup |
| Gradient accumulation | 16 micro-batches (assumed) | 65536 tokens per step; pipeline bubble ~6% |
| Parallelism | TP8 (intra-node), PP2 (cross-node), DP1 | 16 GPUs total; no data-parallel gradient sync |
| Per-GPU memory | 64GB | Kept from the original setup |
| Peak compute | 300 TFLOPS (BF16) | Dense per-GPU figure, no sparsity speedup |
| Interconnect bandwidth (assumed) | Intra-node effective ~200GB/s; PCIe Gen4 x16 ~20GB/s; single 200Gb/s NIC ~25GB/s | Must be replaced with measured values |
2. Model-State Memory
Mixed-precision Adam uses 16 bytes per parameter. With TP8 × PP2 sharding parameters across 16 GPUs, each GPU holds roughly 6.25B parameters, totaling about 100GB of model states.
| Item | Bytes per parameter | Per-GPU usage |
|---|---|---|
| FP16 weights | 2 | 12.5GB |
| FP16 gradients | 2 | 12.5GB |
| FP32 master weights | 4 | 25GB |
| Adam first moment | 4 | 25GB |
| Adam second moment | 4 | 25GB |
| Total | 16 | 100GB |
100GB exceeds the 64GB per-GPU capacity, so without offloading optimizer states, the model states alone do not fit. After offloading the FP32 master weights and both Adam moments, only FP16 weights and gradients remain on the GPU, totaling 25GB.
The 6.25B figure comes from evenly dividing the nominal 100B parameters across 16 GPUs. Actual sharding has two deviations:
- Computed precisely as 12×h², 56 layers give ~101.5B parameters, or ~6.34B per GPU.
- With a 50K vocabulary, the embedding layer has ~610M parameters and sits on the first pipeline stage. After TP8 sharding, each GPU on the first stage carries ~80M extra parameters, totaling ~6.42B, or about 103GB of model states. If the output layer is not tied to the embedding, the last stage grows by the same amount.
The table above excludes activations, communication buffers, memory fragmentation, and the CUDA context. All of these consume memory, so 100GB is only the model state, not the total requirement.
3. Activation Memory
Without recomputation, the per-layer activation estimate (unsharded) is:
Activation bytes per layer ≈ 34×s×b×h + 5×a×s²×b
where s is sequence length, b is micro-batch size, h is hidden size, and a is the number of attention heads. Substituting s=4096, b=1, h=12288, a=96: 34sbh ≈ 1.71GB from linear layers and normalization activations; 5as²b ≈ 8.05GB from the attention score matrix. Unsharded, one layer uses about 9.8GB.
Under TP8, the 24sbh and 5as²b terms tied to linear layers and attention are sharded 8 ways, while the 10sbh terms (layer norm, dropout inputs, etc.) are not. Per GPU per layer:
10sbh + (24sbh + 5as²b)/8 ≈ 0.50 + 1.16 ≈ 1.66GB
The first pipeline stage has 28 layers. With a 1F1B schedule under PP2, the first stage must hold activations for 2 in-flight micro-batches at peak, while the second stage holds only 1. Memory across the three recomputation options (all including the 25GB of GPU-resident model states):
| Option | First-stage peak activation | Total memory | Verdict |
|---|---|---|---|
| No recomputation | 28×1.66×2 ≈ 93GB | ≈118GB | Exceeds 64GB; infeasible |
| Selective recomputation (attention core only) | sbh(10+24/8)×28×2 ≈ 37GB | ≈62GB | Insufficient headroom; fragmentation and communication buffers can easily trigger OOM |
| Full recomputation (store only layer inputs) | 2sbh×28×2 + ~1.7GB for one-layer recompute ≈ 7GB | ≈32GB | Feasible; recommended |
Full recomputation requires one extra forward pass, raising per-step compute from 6NT to 8NT. Under the assumptions above, each step requires about 5.24×10¹⁶ FLOPs.
4. Cross-Machine Communication Volume
With DP1, there is no data-parallel gradient AllReduce. Per-step communication falls into two categories: intra-node TP and cross-node PP.
Intra-node TP communication. Each layer has 2 AllReduces in the forward pass and 2 in the backward pass. With full recomputation, the recomputed forward adds 2 more, for 6 total. Each AllReduce handles a tensor of b×s×h×2 bytes, about 100.7MB. With a ring algorithm, each GPU moves about 2×(8−1)/8×100.7MB ≈ 176MB per AllReduce.
Across 28 layers on the first stage, that is 168 AllReduces per micro-batch, or about 29.6GB per GPU. Over 16 micro-batches, about 474GB per step. At an effective intra-node bandwidth of 200GB/s, this takes roughly 2.4s.
Cross-node PP communication. The first stage sends forward activations to the second stage, and the second stage returns gradients; each is 100.7MB per micro-batch. Over 16 micro-batches, that totals about 3.2GB per step. Over a single 25GB/s link this takes ~0.13s; spread across 8 NICs, ~0.02s.
| Communication type | Data per step | Assumed bandwidth | Estimated time |
|---|---|---|---|
| Intra-node TP AllReduce (per GPU) | ~474GB | 200GB/s | ~2.4s |
| Cross-node PP point-to-point (single link) | ~3.2GB | 25GB/s | ~0.13s |
| Cross-node PP point-to-point (8 NICs) | ~3.2GB | 200GB/s aggregate | ~0.02s |
TP communication dwarfs PP communication, so tensor parallelism must stay on the intra-node high-speed interconnect.
5. The Cost of Optimizer Offloading
With offloading, each GPU must do two things per step: copy FP16 gradients from GPU to host (12.5GB), then copy the updated FP16 weights back to the GPU (12.5GB).
- PCIe transfer: at 20GB/s, each direction takes ~0.6s, totaling ~1.3s. If two GPUs share the same PCIe switch, bandwidth halves and the total becomes ~2.5s.
- CPU Adam update: each host serves 8 GPUs, roughly 50B parameters. At about 28 bytes of memory access per parameter, each step touches ~1.4TB. At an effective host memory bandwidth of 200–300GB/s, this takes ~5–7s. Real-world CPU implementations are usually slower; measure it.
For compute, each GPU performs about 3.28×10¹⁵ FLOPs per step. At the 300 TFLOPS peak, that is ~11s; at 40% utilization (~120 TFLOPS), ~27s. The pipeline bubble adds roughly 6%.
If the ~7–9s of offloading is not overlapped with compute, it amounts to a quarter to four-fifths of compute time. Offloading must therefore overlap with the backward pass, or throughput will drop noticeably.
Host memory requirements.
| Item | Per-host usage | Notes |
|---|---|---|
| Optimizer states (FP32 master weights + Adam states) | ~600GB | 8 GPUs × 75GB |
| Pinned-memory buffers | ~100GB | Assumed; framework-dependent |
| Data loading and OS | ~100GB | Assumed |
| Total | ~800GB; 1TB recommended | Headroom to avoid swapping |
If usable host memory is below 600GB, offloading fails outright. Below 800GB, the system may swap during training and slow down drastically.
6. Stability Checklist and Troubleshooting Order
Troubleshoot in the following order. First confirm offloading and recomputation are enabled, then check memory, communication, throughput, and numerics one by one.
| Symptom | Check first | Command or metric | Threshold |
|---|---|---|---|
| GPU OOM | Is full recomputation on? Does the embedding layer land on the first stage? | nvidia-smi --query-gpu=memory.used,memory.total --format=csv -l 1; torch.cuda.max_memory_allocated() in the framework |
Expected peak ~32GB; warn above ~55GB (85% of 64GB) |
| Communication timeout | Intra-node topology and NCCL transport | nvidia-smi topo -m; set NCCL_DEBUG=INFO to check P2P/NVLink usage; all_reduce_perf from nccl-tests |
Intra-node busbw below ~150GB/s (75% of the assumed value) warrants a topology check; cross-node single link below 20GB/s warrants NIC and RDMA checks |
| Loss anomalies (NaN or spikes) | FP16 overflow; gradient clipping settings; numerical consistency between offloaded and GPU paths | Skip counter of the mixed-precision scaler; gradient-norm curve | Investigate if skip rate exceeds ~1%; pause and check data if the gradient norm jumps to several times its moving average |
| Throughput drop | Is offloading overlapped with compute? Is the host swapping? Is PCIe shared? | free -g; vmstat 1 (si and so columns); nvidia-smi dmon; CPU Adam time in the profiler |
Non-zero so or si means swapping — reduce load immediately; CPU Adam time exceeding backward-pass time means no overlap |
Recommended order: host memory and offloading configuration, memory peak, topology and communication benchmarks, throughput and overlap, numerical stability. The first two surface at startup and should be handled first.
7. Fallbacks When Conditions Are Not Met
- Host memory below 1TB, or cross-node bandwidth well below the assumptions: shorten the sequence first. The dominant activation terms scale linearly or quadratically with sequence length; dropping from 4096 to 2048 reduces the 5as²b term to about a quarter.
- Memory still tight: use more GPUs. For example, scaling to 4 machines and 32 GPUs roughly halves the offloaded state per host.
- Throughput below target: first confirm with measured data whether offloading overlaps the backward pass, then decide whether to adjust micro-batch count or pipeline depth.
8. Limitations
All numbers in this article are based on assumptions, including the number of attention heads, embedding vocabulary size, auxiliary host-memory usage, CPU Adam memory bandwidth, and NIC count. Replace these assumptions with your own cluster’s memory measurements, nccl-tests results, PCIe topology, and profiler data before deciding whether the model fits.
