Two lines of code, multi-GPU or TPU
TF's distribution API wraps a single-device script to run across multiple GPUs or TPU chips with minimal code changes. Create a strategy, build and compile inside strategy.scope(), and model.fit handles gradient synchronization automatically.
| Strategy | Hardware | Sync | Status |
|---|---|---|---|
| MirroredStrategy | 1 machine, N GPUs | Sync (NCCL) | Stable |
| TPUStrategy | TPU pod / v2/v3/v4 | Sync | Stable |
| MultiWorkerMirroredStrategy | N machines × N GPUs | Sync | Stable |
| ParameterServerStrategy | N workers + param servers | Async | Experimental |
Scale the global batch size with the number of replicas. A per-replica batch of 64 across 4 GPUs is a global batch of 256. Match learning rate accordingly (linear scaling rule, plus warmup for very large batches).