How it works
- Weights = parameters × bytes per parameter: 2 at 16-bit, 1 at 8-bit, about 0.56 at 4-bit (including quantisation scales).
- KV cache = 2 × layers × KV heads × head size × bytes × context × users. It grows with every token and every user.
- Overhead = about 10% of the weights plus 1 GB for the CUDA context and serving software.
- The calculator then lists the cheapest on-demand GPUs that fit, from our GPU price data.
GPU VRAM calculator
- Weights
- —
- KV cache
- —
- Overhead
- —
Cheapest GPUs that fit, on demand:
- Turn on JavaScript to use the calculator.
Vultr GPUs open now for this: A40 ($1.712/h, 2 regions) and A100 80 GB ($2.397/h, New Jersey).
Memory for popular models at an 8K context
One request at a time, 16-bit KV cache. Under each figure, the smallest GPU setup that holds it with 5% to spare.
| Model | 16-bit | 8-bit | 4-bit |
|---|---|---|---|
| Llama 3.1 8B | 20 GB1 × 24 GB | 11 GB1 × 24 GB | 7 GB1 × 24 GB |
| Qwen2.5 7B | 18 GB1 × 24 GB | 10 GB1 × 24 GB | 6 GB1 × 24 GB |
| Qwen2.5 14B | 35 GB1 × 48 GB | 19 GB1 × 24 GB | 12 GB1 × 24 GB |
| Qwen2.5 32B | 75 GB1 × 80 GB | 39 GB1 × 48 GB | 23 GB1 × 48 GB |
| Llama 3.3 70B | 159 GB1 × 180 GB | 81 GB1 × 141 GB | 47 GB1 × 80 GB |
| Qwen2.5 72B | 164 GB1 × 180 GB | 84 GB1 × 141 GB | 49 GB1 × 80 GB |
How big the KV cache gets
Per token at 16-bit, and for a full 32K-token context. Models with fewer KV heads (grouped-query attention) keep the cache small; multiply by the number of requests served at once.
| Model | Layers | KV heads | Per token | 32K tokens |
|---|---|---|---|---|
| Llama 3.1 8B | 32 | 8 | 0.13 MB | 4.3 GB |
| Qwen2.5 7B | 28 | 4 | 0.06 MB | 1.9 GB |
| Qwen2.5 14B | 48 | 8 | 0.20 MB | 6.4 GB |
| Qwen2.5 32B | 64 | 8 | 0.26 MB | 8.6 GB |
| Llama 3.3 70B | 80 | 8 | 0.33 MB | 10.7 GB |
| Qwen2.5 72B | 80 | 8 | 0.33 MB | 10.7 GB |
Making a model fit
- Lower the weight precision. 8-bit roughly halves the weights with little quality loss; 4-bit quarters them, with some loss on harder tasks.
- Cap the context. Serving software reserves memory for the longest context you allow. In vLLM, set
--max-model-len; in Ollama, the context length setting. - Use an 8-bit KV cache if your server supports it: it halves the cache.
- Split across GPUs only when you must: 2, 4 or 8 GPUs, and the price scales with them.
Next: which GPU for LLM inference, and how to serve a model with vLLM or Ollama.
Related guides
Sources
- Llama 3.1 8B config.json: layers, KV heads and head size.
- Qwen2.5 7B config.json: layers, KV heads and head size.
- Qwen2.5 14B config.json: layers, KV heads and head size.
- Qwen2.5 32B config.json: layers, KV heads and head size.
- Llama 3.3 70B config.json: layers, KV heads and head size.
- Qwen2.5 72B config.json: layers, KV heads and head size.
- vLLM documentation: KV cache, FP8 KV cache and tensor parallelism.
- GPU prices: our GPU price data, from each provider's pricing page or API.
Questions people ask
How much VRAM do I need to run an LLM?
Model weights (parameters times bytes per parameter), plus the KV cache for your context and users, plus about 10% and 1 GB for the serving software. An 8B model at 16-bit with an 8K context needs about 20 GB; a 70B model at 4-bit about 47 GB.
What is the KV cache?
The keys and values a model keeps for every token already in the context, so it does not recompute them. It grows with context length and with the number of requests served at once, and can be larger than the model on long contexts.
Does quantising the model shrink the KV cache?
No. Weight precision and KV cache precision are separate settings. Servers such as vLLM can store the KV cache in 8-bit (FP8), which halves it; pick that in the calculator.
Why does the calculator jump from 1 to 2, 4 or 8 GPUs?
Serving software splits a model across GPUs in powers of two (tensor parallelism), and cloud servers come with 1, 2, 4 or 8 GPUs.
How accurate is this?
Within a few gigabytes for standard dense models. Real use varies with the serving software, its settings and the model architecture. Leave headroom, then test on an hourly GPU before committing.