GPU memory requirement calculator for simulations and neural networks
Updated · Scientifically reviewed by Priyank Srivastava, PhD on
Short answer
For grid simulations, memory ≈ grid points × variables per point × bytes per value × copies (time levels, temporaries) plus overhead for halos and workspace. For neural-network training, weights, gradients and optimizer states take about 16 bytes per parameter with FP32 Adam (and also with mixed precision, because of the FP32 master copy), plus activations that grow with batch size. The two calculators below estimate both.
Who this is for
Researchers sizing GPUs for grid-based simulations or neural-network training, and teams choosing between GPU models or cloud instances.
Grid simulation GPU memory calculator
Results update as you type. Scientific notation such as 1e18 is accepted.
| Estimated GPU memory | — |
|---|
Neural network GPU memory calculator
Results update as you type. Scientific notation such as 1e18 is accepted.
| Weights only (inference) | — | |
|---|---|---|
| Training: weights + grads + optimizer (excl. activations) | — |
Formula
Grid-based simulation:
Neural-network training state (excluding activations):
with , the weight and gradient bytes (4 for FP32, 2 for FP16/BF16), for mixed precision and 0 otherwise, and FP32 optimizer states per parameter (Adam: 2, SGD with momentum: 1).
Worked example
3D grid simulation: points, 8 variables, FP64, 2 copies, 20% overhead:
which fits on a single 40 GB GPU but not a 16 GB one.
Neural network, 1 billion parameters, Adam:
- FP32: GB for training state, 4 GB for inference weights.
- BF16 mixed precision: GB for training state, 2 GB for BF16 inference weights.
Add activations on top: for large models these often decide how much fits.
Where it is used
- Choosing GPUs and instance types, then comparing costs with the HPC Cost Estimator.
- Planning domain decomposition for simulations; for particle codes use the PIC memory calculator.
- Diagnosing out-of-memory errors; see CUDA out of memory.
Assumptions and limitations
- Estimates exclude activation memory (neural networks), library workspaces, CUDA context and fragmentation.
- Optimizer variants (8-bit optimizers, Adafactor) and sharding change the per-parameter cost.
- Simulation codes may store more or fewer arrays than assumed, so check against a short test run.
Frequently asked questions
Why does mixed precision not reduce optimizer memory?+
Standard mixed-precision training keeps FP16/BF16 weights and gradients for speed, but also an FP32 master copy of the weights and FP32 optimizer states for stability. Per parameter that is 2 + 2 + 4 + 8 = 16 bytes with Adam, the same as FP32. Mixed precision mainly saves activation memory and increases throughput.
Why are activations not included?+
Activation memory depends on architecture, batch size, sequence or image size, and whether activation checkpointing is used. It can exceed the parameter-related memory. Measure it with torch.cuda.max_memory_allocated() on a small batch and scale.
How much memory is left for my data?+
The CUDA context and libraries reserve some memory (often several hundred MB to a few GB), and allocators fragment memory. Plan to use no more than about 85–90% of nominal GPU memory.
How do I fit a model that does not fit?+
Reduce batch size (with gradient accumulation), use activation checkpointing, shard parameters and optimizer states across GPUs (FSDP/ZeRO), or offload to CPU memory. For simulations, decompose the domain across more GPUs.
References
- CUDA semantics: memory management · PyTorch documentation
- Rajbhandari et al., ZeRO: memory optimizations toward training trillion parameter models (SC20) · Conference paper
- Micikevicius et al., Mixed precision training (ICLR 2018) · Conference paper (arXiv)
Planning a real simulation?
Estimates are the start. We design, run and verify the full simulation, with convergence checks and documented limits.
Services listed on this page are available today. Products marked “early access” or “in development” on our platform page are not yet generally available.
Spotted an error or an outdated command? Tell us. We correct verified issues promptly.