LLM VRAM Estimator
Estimate GPU memory to run or fine-tune an LLM, and see which GPUs it fits on.
How it works
Inference
- Weights =
params × bytes per parameter(fp32 = 4, fp16/bf16 = 2, int8 = 1, int4 = 0.5). - KV cache =
2 × layers × hidden × context × batch × bytes. The 2 is for keys and values. It grows linearly with context and batch size, so long contexts can cost more than the weights. - Overhead: 10% on top for the CUDA context, temporary buffers and fragmentation.
Training (Adam, mixed precision)
About 16 bytes per parameter: fp16 weights (2) + fp16 gradients (2) + fp32 master weights (4) + Adam first moment (4) + Adam second moment (4). Activation memory is extra and depends on batch size, sequence length and whether you use gradient checkpointing.
Units and limits
Sizes are in GB where 1 GB = 230 bytes, matching how GPU memory is advertised. This is an estimate: grouped-query attention shrinks the KV cache, while framework overhead and activations can push real usage higher.
Related tools
Param Counter
Count parameters and fp32 memory for Dense, Conv2D, Embedding, LayerNorm and attention layers.
Token Counter
Count GPT tokens, characters and words, with token boundaries highlighted.
Conv Shape Calculator
Track tensor shapes through stacked Conv2D, MaxPool and AvgPool layers.