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.

Unit: Billion Params
Unit: Layers
Unit: 2 × KV heads × head dim
Unit: Tokens
Unit: Concurrency
Unit: GB
Needs about 2 × 80 GB GPUs (147.17 GB estimated)
Total VRAM Estimate 147.17 GB
Model Weights 140.0 GB
KV Cache 5.37 GB
GPUs Needed 2 × 80 GB
Weights take 140.0 GB. The KV cache stores 327,680 bytes per token (80 layers × 2048 values × 2 bytes), so 8,192 tokens for 2 concurrent sequences need 5.37 GB. Real usage depends on the inference framework, which may reserve memory up front, and on activations during prefill.
Calculation: Total = 70 × 16 ÷ 8 + 80 × 2048 × 2 × 8,192 × 2 ÷ 10⁹ + 1.8 = 147.17 GB
Calculation basis: Weights = parameters × bits ÷ 8. KV cache = layers × values cached per layer × bytes × tokens × concurrent sequences, using each preset's published architecture. Adds 1.8 GB runtime overhead and assumes about 92% of each GPU's memory is usable. Figures are decimal GB.

How to Use This Calculator

  1. 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.
  2. Choose the weight precision and the KV cache precision.
  3. 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.