LLM GPU Memory Calculator: Weights, KV Cache and GPU Count
Estimate how much GPU memory a large language model needs for its weights and KV cache, and how many GPUs that means.
How to Use This Calculator
- Choose a model. The parameter count, layer count and KV values per layer fill in from its published configuration; choose Custom to enter your own from the model's config.json.
- Choose the weight precision and the KV cache precision.
- Set the context length, the number of sequences served at once and the memory of one GPU.
Frequently Asked Questions
How is total GPU memory estimated?
Weights (parameters × bytes per parameter) plus the KV cache (bytes per token × tokens × concurrent sequences) plus a fixed 1.8 GB for the runtime. Frameworks such as vLLM reserve a share of GPU memory up front, so measured usage can be higher.
Where do the layer and KV figures come from?
From each model's config.json or technical report: num_hidden_layers, num_key_value_heads and head dimension. For standard attention the values per layer are 2 × KV heads × head dim, for example 2 × 8 × 128 = 2,048 for Llama 3 70B. DeepSeek-V3 and R1 use multi-head latent attention and cache 512 + 64 = 576 values per layer.
Why does the KV cache grow with context and concurrency?
Each token keeps its keys and values in memory so later tokens can attend to them, and every sequence has its own cache. Doubling the context or the number of concurrent sequences doubles the cache.
Planning note: Results are planning estimates. Actual memory consumption, throughput, and power draw depend on inference runtime implementation (e.g. vLLM vs llama.cpp), batch size, and sequence context length. Benchmark your specific workload on physical hardware before purchasing.