Skip to content
VLASIFY™
CalculatorCalculators & technical tools

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.

Grid simulation GPU memory results
Estimated GPU memory—

Neural network GPU memory calculator

Results update as you type. Scientific notation such as 1e18 is accepted.

Neural network GPU memory results
Weights only (inference)—
Training: weights + grads + optimizer (excl. activations)—

Formula

Grid-based simulation:

M=Npoints×nvars×b×ncopies×(1+foverhead).M = N_{points}\times n_{vars}\times b\times n_{copies}\times(1 + f_{overhead}).

Neural-network training state (excluding activations):

Mtrain=Nparams (bw+bg+bmaster+4 nopt),Minference=Nparams bw,M_{train} = N_{params}\,(b_w + b_g + b_{master} + 4\,n_{opt}), \qquad M_{inference} = N_{params}\,b_w,

with bwb_w, bgb_g the weight and gradient bytes (4 for FP32, 2 for FP16/BF16), bmaster=4b_{master} = 4 for mixed precision and 0 otherwise, and noptn_{opt} FP32 optimizer states per parameter (Adam: 2, SGD with momentum: 1).

Worked example

3D grid simulation: 5123=1.34×108512^3 = 1.34\times10^{8} points, 8 variables, FP64, 2 copies, 20% overhead:

M=1.34×108×8×8 B×2×1.2≈20.6 GB,M = 1.34\times10^{8}\times8\times8\ \text{B}\times2\times1.2 \approx 20.6\ \text{GB},

which fits on a single 40 GB GPU but not a 16 GB one.

Neural network, 1 billion parameters, Adam:

  • FP32: 109×(4+4+0+8)=1610^{9}\times(4 + 4 + 0 + 8) = 16 GB for training state, 4 GB for inference weights.
  • BF16 mixed precision: 109×(2+2+4+8)=1610^{9}\times(2 + 2 + 4 + 8) = 16 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

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

  1. CUDA semantics: memory management · PyTorch documentation
  2. Rajbhandari et al., ZeRO: memory optimizations toward training trillion parameter models (SC20) · Conference paper
  3. 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.

Related guides

How Vlasify can help

Get a Quote