LLM VRAM requirements depend on more than parameter count. This guide gives you a repeatable GPU sizing method that accounts for quantized model weights, KV cache, runtime overhead, context length, concurrency, and a safety margin, with reference tables and a spreadsheet-ready worksheet you can reuse for local or cloud deployments.
Overview
The amount of GPU memory needed for LLM inference is primarily the sum of four components:
- Model weights: The loaded parameters, usually reduced with formats such as 8-bit or 4-bit quantization.
- KV cache: Attention key and value states retained for each token in the context window and each active sequence.
- Runtime overhead: Memory used by the inference engine, temporary tensors, CUDA allocations, buffers, and quantization metadata.
- Safety margin: Uncommitted capacity that prevents small workload changes from causing an out-of-memory error.
A useful planning formula is:
Total VRAM = model weights + KV cache + runtime overhead + safety margin
Parameter count alone is therefore an incomplete sizing method. A model may fit when loaded with a short prompt and one request, then fail when context length, batch size, or concurrent sessions increase. Advertised GPU memory is also not always fully available to an inference process, so treat the card's nominal capacity as an upper bound rather than a target.
The figures below are calculated estimates, not documented benchmark measurements. Actual usage varies by model architecture, inference engine, quantization implementation, GPU, and runtime configuration.
How to estimate
1. Estimate the weight footprint
Start with the parameter count and storage precision:
Raw weight memory in GB ≈ parameters in billions × bits per parameter ÷ 8
This produces a useful first estimate. It does not include scales, zero points, alignment, metadata, duplicated tensors, or engine-specific allocations. For planning, add an explicit weight overhead factor instead of assuming that a “4-bit” model uses exactly four bits for every stored value.
| Model size | FP16 raw weights | 8-bit raw weights | 4-bit raw weights |
|---|---|---|---|
| 7B | 14 GB | 7 GB | 3.5 GB |
| 13B | 26 GB | 13 GB | 6.5 GB |
| 34B | 68 GB | 34 GB | 17 GB |
| 70B | 140 GB | 70 GB | 35 GB |
These are arithmetic reference points using decimal GB. They are not claims about the installed size of a particular checkpoint. A practical worksheet should include a measured or documented file size when available, then reserve additional room for loading.
2. Calculate KV cache memory
For a decoder-only transformer, an illustrative KV cache formula is:
KV cache bytes = 2 × layers × KV heads × head dimension × tokens × bytes per value × active sequences
The first factor of two represents keys and values. “Tokens” should include the maximum retained context for each sequence, including the prompt and generated output if the engine retains both. Use the model's KV-head count, not automatically its total attention-head count; grouped-query and multi-query attention can materially change the result.
For example, assume 32 layers, 8 KV heads, a head dimension of 128, FP16 KV values, a 4,096-token context, and one active sequence:
2 × 32 × 8 × 128 × 4,096 × 2 bytes ≈ 0.5 GiB
Doubling context to 8,192 tokens approximately doubles this component. Doubling concurrent sequences also approximately doubles it. This is why a model that fits an interactive test may fail under production concurrency.
3. Add runtime overhead and a margin
Runtime overhead is engine- and configuration-dependent. It can include temporary workspace, allocator fragmentation, CUDA graphs, attention kernels, CPU-to-GPU staging, tensor-parallel communication buffers, and quantization metadata. When exact measurements are unavailable, represent this as a separate assumption rather than hiding it inside the weight estimate.
A spreadsheet-ready worksheet can use these rows:
| Input or calculation | Spreadsheet value |
|---|---|
| Parameter count in billions | Enter model value |
| Weight bits per parameter | 2, 4, 8, or 16 |
| Raw weights in GB | Parameters × bits ÷ 8 |
| Weight overhead factor | Enter an engine/checkpoint-specific assumption |
| Loaded weights | Raw weights × overhead factor |
| Transformer layers | Enter model configuration |
| KV heads | Enter model configuration |
| Head dimension | Enter model configuration |
| Context tokens | Maximum retained tokens |
| Active sequences | Expected concurrent sequences |
| KV bytes per value | 2 for FP16/BF16; verify runtime setting |
| KV cache | 2 × layers × KV heads × head dimension × tokens × sequences × bytes |
| Runtime overhead | Measured value or documented estimate |
| Safety margin | Chosen reserve in GB or GiB |
| Total required VRAM | Loaded weights + KV cache + overhead + margin |
Inputs and assumptions
Record assumptions beside every estimate. At minimum, capture the model revision, quantization format, inference engine and version, context limit, maximum output length, concurrency target, KV-cache precision, and whether the deployment uses single-GPU or distributed inference.
Do not treat quantization labels as interchangeable. Two checkpoints described as 4-bit may use different group sizes, scales, metadata, kernels, and loading behavior. Confirm whether the engine keeps some layers or tensors in higher precision. Similarly, a model's context limit is not the same as the context used in every request; sizing should use the maximum operational target, not an optimistic average.
Concurrency needs careful definition. “Ten users” might mean ten active generations, ten queued requests, or ten sessions whose KV caches remain resident. Only the resident active sequences directly affect the basic KV calculation, while batching and scheduler behavior can add other workspace requirements.
For production AI workflows, validate the worksheet with a controlled load test. Log peak allocated and reserved memory, prompt length, generated tokens, active sequences, and errors. Pair the result with an evaluation and observability process, such as the AI workflow observability guide. Capacity planning should also account for rate limits and queue behavior; see the LLM API rate limits guide when the deployment is cloud-hosted or API-backed.
Worked examples
Example A: 7B model at 4-bit quantization
The raw weight estimate is 7 × 4 ÷ 8 = 3.5 GB. Suppose the worksheet reserves an illustrative 15% for weight-related overhead, producing about 4.0 GB for loaded weights. Using the earlier 32-layer KV assumptions, one 4,096-token sequence adds approximately 0.5 GiB. If runtime overhead is provisionally set to 1.5 GB and the deployment keeps a 2 GB safety margin, the planning total is roughly 8 GB, subject to validation. A larger context or several active sequences increases the KV line directly.
Example B: 13B model at 8-bit quantization
The raw weight estimate is 13 GB. With the same illustrative 15% loading allowance, the weight line becomes about 15 GB before KV cache and runtime memory. A GPU with a similar nominal capacity would leave little room for the cache and operating margin, even if the checkpoint appears to fit during loading. In this situation, reduce precision only after checking quality requirements, use a larger-memory GPU, or reduce the maximum context and concurrency target.
Example C: 70B model at 4-bit quantization
The raw weight estimate is 35 GB. A 15% illustrative allowance puts loaded weights near 40.25 GB before any KV cache or runtime allocations. A deployment of this size may require a higher-memory accelerator or multiple GPUs, depending on the engine's support for sharding and the target workload. Do not select hardware from the raw 35 GB figure alone; the remaining capacity must cover cache, workspace, communication buffers, and margin.
These examples demonstrate the method rather than guarantee a specific model will fit. Replace the illustrative overhead values with measurements from the exact checkpoint and engine before committing to hardware.
When to recalculate
Revisit the LLM GPU sizing worksheet whenever any memory-driving input changes. Recalculate after changing the model checkpoint, quantization format, inference engine, GPU type, context limit, maximum output length, KV-cache precision, batch size, or concurrency target. Recheck it after engine upgrades because allocator behavior, kernels, supported formats, and memory settings may change.
Also recalculate when production traffic changes. A growing prompt, longer tool-calling chain, more simultaneous users, or a new RAG configuration can increase resident tokens and KV usage even when the model itself is unchanged. For RAG deployments, measure the final assembled prompt rather than estimating from the user's question alone.
Use this practical sequence:
- Copy the model configuration and checkpoint details into the worksheet.
- Calculate raw and loaded weight memory separately.
- Calculate KV cache using maximum tokens and active sequences.
- Add measured runtime overhead and a visible safety margin.
- Run a staged test at target context and concurrency.
- Record peak memory, out-of-memory errors, latency, and quality results.
- Update the worksheet after each model or infrastructure change.
If you encounter an out-of-memory error, first reduce concurrency or context to identify which component is responsible. Then inspect whether the model loaded in the intended quantization, whether another process occupies VRAM, and whether the engine reserves memory aggressively. Only after measuring should you change precision or split the model across devices. This keeps GPU sizing connected to the real AI development workflow rather than relying on a parameter-count shortcut.