Inference GPU Memory Requirements Explained for LLM Serving

Inference GPU Memory Requirements Explained for LLM Serving

Inference GPU memory requirements are the amount of graphics memory a language model needs to load its weights and serve requests, and they decide which GPU can run your model at all. How much memory does LLM inference actually need, and what sets inference GPU memory requirements? A 7-billion-parameter model in 16-bit precision needs about 14 GB for its weights alone, and the KV cache for active requests can easily need as much again, so a realistic budget for serving that model is 24 to 40 GB depending on context length and concurrency.

Getting this number wrong is expensive in both directions. Underestimate it and the server crashes with out-of-memory errors under load. Overestimate it and you pay for a larger GPU than the workload needs, month after month.

Key takeaways

  • Model weights are the fixed cost: roughly 2 bytes per parameter in 16-bit precision, 1 byte in 8-bit, and half a byte in 4-bit.
  • The KV cache is the variable cost: it grows with every token of every active request and often exceeds the weights at high concurrency.
  • A 7B model in FP16 needs about 14 GB for weights; a 70B model needs about 140 GB, which no single 80 GB card can hold.
  • Quantisation, grouped-query attention and PagedAttention are the three biggest levers for cutting memory use.
  • Always leave headroom for activations, CUDA overhead and traffic spikes, and measure with real traffic before committing to hardware.

What makes up inference GPU memory requirements?

GPU memory during inference holds four things. The largest fixed item is the model weights: every parameter of the model must sit in memory, and the size follows directly from the parameter count and the precision. A 7B model at 16-bit precision holds 7 billion values at 2 bytes each, which is about 14 GB. The same model in 8-bit precision needs about 7 GB, and in 4-bit precision about 3.5 GB.

The second item is the KV cache. During generation, the model stores the key and value tensors for every token it has already processed, so it does not have to recompute them for each new token. This cache grows with sequence length and with the number of simultaneous requests, and it is the item most teams underestimate. For a 13B model with full multi-head attention, the cache can reach roughly 800 KB per token, so one 2,048-token conversation needs about 1.7 GB, and eight such conversations need more than 13 GB.

The third and fourth items are smaller but real: activations for the batch currently being computed, and overhead from the CUDA runtime, the serving engine and memory fragmentation. A common planning rule is to reserve 5 to 10 per cent of the card for overhead on top of weights and cache.

The KV cache formula, worked out

You can calculate KV cache size exactly from the model configuration. The formula is 2 (for keys and values) multiplied by the number of layers, the number of key-value heads, the head dimension and the bytes per value. For a model using grouped-query attention, the key-value head count is smaller than the query head count, which is why modern models use far less cache than older ones of the same size.

Take Llama 3 8B as an example. It has 32 layers, 8 key-value heads and a head dimension of 128, stored in 2 bytes per value. That gives 2 × 32 × 8 × 128 × 2, or 131,072 bytes per token — about 128 KB. A 4,096-token conversation therefore needs about 512 MB of cache, and 32 such conversations need about 16 GB. This is the arithmetic behind every capacity decision, and it comes straight from the model card.

The same formula explains why long-context serving is so memory hungry. Doubling the context length doubles the cache per request, and doubling the batch doubles it again. Context length, not parameter count, is usually what breaks a serving setup that worked in testing.

Weights by model size and precision

Model size FP16 / BF16 weights INT8 weights INT4 weights Fits on one 80 GB card?
7B parameters About 14 GB About 7 GB About 3.5 GB Yes, easily
13B parameters About 26 GB About 13 GB About 6.5 GB Yes
32B parameters About 64 GB About 32 GB About 16 GB Yes, tight at FP16
70B parameters About 140 GB About 70 GB About 35 GB No at FP16; yes at INT8
405B parameters About 810 GB About 405 GB About 203 GB No; needs many cards

Best for: teams sizing a first deployment should start from this table, then add the KV cache budget for their real context lengths and concurrency before choosing a card.

Which GPU fits which model?

The most common data-centre cards for inference are the NVIDIA A100 and H100, both available with 80 GB of memory. The A100 80GB uses HBM2e memory at about 2 TB/s of bandwidth, while the H100 80GB uses HBM3 at about 3.35 TB/s. The H100 therefore moves data faster, which matters for large batches, but both cards hold the same size of model.

For smaller deployments, consumer cards can work surprisingly well. An RTX 4090 has 24 GB of memory, which comfortably holds a 7B model in FP16 with room for a modest KV cache, and a 13B model in 8-bit precision. It is a sensible choice for development and low-traffic internal tools, though it lacks the error-correcting memory of data-centre cards, so it is rarely right for production.

When a model does not fit on one card, the standard answer is tensor parallelism: split the model across two or more GPUs so each holds a slice of the weights and the cache. A 70B model in FP16 needs two 80 GB cards at minimum, and a 405B model needs a whole rack. Matching GPUs to your model is worth doing carefully, because the wrong split wastes both memory and money.

A graphics card with glowing memory chips in a server rack
GPU memory is split between model weights, the KV cache for active requests, activations and overhead — and the cache is the part that grows with traffic.

How quantisation changes the maths

Quantisation stores weights at lower precision, and it is the single most effective way to cut memory requirements. Dropping from 16-bit to 8-bit precision halves the weight memory and usually costs very little accuracy on modern models. Dropping to 4-bit precision quarters it, with a small but measurable quality cost on some tasks. The trade-off is real, so quantised models should be evaluated on your own prompts rather than accepted on faith.

Quantisation also shrinks the KV cache if the cache itself is quantised. Several serving engines support 8-bit or 4-bit KV cache, which can double or quadruple the number of concurrent requests that fit on a card. Combined with grouped-query attention, the cache per token can fall by an order of magnitude compared with older architectures.

There is a catch worth knowing. Lower precision reduces memory use but does not always increase speed by the same factor, because inference at small batch sizes is limited by memory bandwidth, not compute. FP8 inference helps on H100 hardware, where the tensor cores support it natively, but the benefit depends on the engine and the batch size.

PagedAttention and memory fragmentation

Traditional serving engines pre-allocated a fixed block of memory for each request at its maximum possible length, which wasted most of it: a request that might reach 4,096 tokens but actually used 200 still held the full allocation. The vLLM project measured this waste at 60 to 80 per cent of allocated KV cache memory in older systems.

Common mistakes when sizing GPU memory

The first mistake is budgeting for weights only. A 7B model fits on a 16 GB card by the weights table, but add a realistic KV cache and the same card is out of memory at a handful of concurrent users. Always budget weights plus cache plus overhead, and test with the concurrency you expect at peak, not at average load.

The second mistake is testing with short prompts and deploying to long ones. A system that passes load tests with 512-token prompts can fail on its first day with 8,000-token documents, because the cache per request is sixteen times larger. Load tests should use the longest realistic prompts, not the shortest convenient ones.

The third mistake is ignoring the memory cost of prefix caching and speculative decoding. Both improve speed, but prefix caching holds shared prompt blocks in memory and speculative decoding holds a draft model alongside the main one. KV cache optimisation techniques such as cache quantisation and sliding-window attention can recover much of that headroom when it matters.

Sizing checklist

Work through this checklist before you rent or buy a GPU for inference.

  • Write down the model size, precision and architecture details: layers, key-value heads and head dimension.
  • Calculate weight memory from parameters times bytes per value, and check it against the card capacity.
  • Calculate KV cache per token from the formula, then multiply by your 95th-percentile context length and target concurrency.
  • Add 5 to 10 per cent for activations, CUDA overhead and fragmentation.
  • Decide whether quantisation is acceptable, and evaluate the quantised model on your own prompts first.
  • Check whether the engine supports PagedAttention, prefix caching and KV cache quantisation.
  • Load-test with realistic prompts and peak concurrency, and watch memory use rather than trusting the estimate alone.
  • Plan for growth: leave room for longer contexts and more users, or a clear path to a second card.

Frequently asked questions

How much GPU memory do I need for LLM inference?

It depends on the model, the precision and the workload. A 7B model in FP16 needs about 14 GB for weights, plus KV cache that grows with context length and concurrency, so plan on 24 to 40 GB for a small production setup. A 70B model needs about 140 GB for weights in FP16, which means at least two 80 GB cards.

What uses the most GPU memory during inference?

At low concurrency, the model weights dominate. At high concurrency or long context lengths, the KV cache usually dominates, and it can exceed the weights several times over. Activations and overhead are comparatively small but still worth reserving room for.

Does quantisation reduce inference GPU memory requirements?

Yes. INT8 halves weight memory and INT4 quarters it, with a small quality trade-off that should be measured on your own prompts. Quantising the KV cache as well can double or quadruple the number of concurrent requests that fit on one card.

Can a 70B model run on a single 80 GB GPU?

Not in FP16, because the weights alone need about 140 GB. It can fit on one 80 GB card in INT8, at about 70 GB, though with little room left for the KV cache. In practice most teams serve 70B models across two or more cards, or use 4-bit quantisation.

How do I calculate KV cache size?

Multiply 2 by the number of layers, the number of key-value heads, the head dimension and the bytes per value. That gives bytes per token; multiply by the sequence length for one request, and by the number of concurrent requests for the total. The numbers come from the model configuration file.

Why does my server run out of memory under load but not in testing?

Testing usually runs one request at a time with short prompts, while production brings many simultaneous requests with longer prompts. Each request adds KV cache, so memory use rises with concurrency and context length. Load-test with realistic prompts at peak concurrency to find the real limit.

Latest articles

Scroll to Top