Skip to content

NVIDIA GPU sizing for LLM inference: the memory arithmetic

Updated 6 min readFor ML platform engineers and infrastructure owners buying or renting inference GPUs

Size an inference GPU by working out weight memory, then seeing how much KV cache the remainder holds at your context length and concurrency. Weights per GPU equal parameters times bytes per parameter, divided by tensor parallelism, and KV cache per token is 2 times layers times KV heads times head dimension times bytes per element. A model can fit and still serve only one long request at a time. The arithmetic picks which configurations to test, and only a load test gives you latency and throughput.

Fitting the weights is the easy half

The usual sizing mistake is to compare the size of the model file with the memory on the card, see that it fits, and place the order. Then the service starts, handles one long request, and queues everything else. The buyer forgot the second half of the budget, the KV cache, and it grows with every token of every request in flight.

NVIDIA’s support matrix makes the distinction explicit. It defines minimum VRAM per GPU as the memory needed to load the weights and runtime allocations, and adds that this excludes KV cache headroom for long context or high concurrency. A published minimum tells you the model starts. It says nothing about your workload.

Outside the engine’s fraction1 minus the memory fraction settingKV cacheWhat remains; sets concurrencyActivations and runtimeMeasured at startup; varies by engineModel weightsParameters × bytes per parameter ÷ TPOutside the engine’s fraction1 minus the memory fraction settingKV cacheWhat remains; sets concurrencyActivations and runtimeMeasured at startup; varies by engineModel weightsParameters × bytes per parameter ÷ TP
Only the KV cache layer scales with users. Everything beneath it is taken off the top before the first request arrives.

The two formulas

NVIDIA’s memory guide gives the estimate for weights: total parameters times bytes per parameter, divided by the tensor-parallel degree. BF16 and FP16 use 2 bytes per parameter, FP8 uses 1, and INT4 and NVFP4 use 0.5. Its own example puts a 70-billion-parameter model at 35 GB per GPU either as BF16 across four GPUs or as FP8 across two.

KV cache per token follows from the model’s shape. Together AI’s write-up states it as 2 times the number of layers, times KV heads, times head dimension, times bytes per element. The 2 covers one key and one value. Take num_key_value_heads from the model’s config and ignore the attention head count, since models using grouped-query attention can have far fewer KV heads. A missing head_dim can be derived as hidden size divided by attention heads. Total cache is bytes per token, times tokens per request, times concurrent requests. Some architectures don’t fit this formula, so check yours.

Model (invented): 70e9 parameters, 80 layers, 8 KV heads, head_dim 128

Weights:  BF16  70e9 x 2   = 140 GB
          FP8   70e9 x 1   =  70 GB
          4-bit 70e9 x 0.5 =  35 GB

KV per token at 2 bytes per element:
  2 x 80 x 8 x 128 x 2 = 327,680 bytes

Per request at full 8,192-token context:
  327,680 x 8,192 = 2.68 GB

Target: 16 full-context requests at once:
  2.68 GB x 16 = 42.9 GB across the deployment

Budget per 80 GB GPU at a 0.92 memory fraction:
  80 x 0.92 = 73.6 GB
Assumed activations and runtime (invented): 2 GB per GPU

Four configurations of the same model

Using those numbers, take each configuration’s budget, subtract weights and runtime, and divide what’s left by the per-request cost. H100 SXM is listed at 80 GB per GPU, and the 0.92 is the current default for vLLM’s --gpu-memory-utilization, documented in the engine arguments reference. Under tensor parallelism the weights and the cache both spread across GPUs, so the simplest calculation multiplies the per-GPU remainder by the GPU count and compares that with the total cache needed.

I’ve kept the cache at 2 bytes per element throughout, the conservative case for quantized models. vLLM’s --kv-cache-dtype defaults to auto, using the model’s data type, so a cache stored at 1 byte per element would need half as much. Confirm what your engine does, since that alone can double your concurrency estimate.

ConfigurationWeights per GPUKV cache: per GPU × GPUsFull-context requests
2 GPUs, BF1670 GB(73.6 − 70 − 2) = 1.6 × 2 = 3.2 GB3.2 ÷ 2.68 = 1
1 GPU, 4-bit35 GB(73.6 − 35 − 2) = 36.6 × 1 = 36.6 GB36.6 ÷ 2.68 = 13
2 GPUs, FP835 GB(73.6 − 35 − 2) = 36.6 × 2 = 73.2 GB73.2 ÷ 2.68 = 27
4 GPUs, BF1635 GB(73.6 − 35 − 2) = 36.6 × 4 = 146.4 GB146.4 ÷ 2.68 = 54
2 GPUs, BF1611 GPU, 4-bit132 GPUs, FP8274 GPUs, BF16542 GPUs, BF1611 GPU, 4-bit132 GPUs, FP8274 GPUs, BF1654
Synthetic example, calculated from invented model figures. Two GPUs at full precision run the model and hold one long request, while quantizing the same two GPUs gives 27.

Reading the four rows

The first row is the trap. The model fits on two GPUs at BF16, a quick test succeeds, and the service can hold one request of that length at a time. Requests shorter than the maximum hold more: at an average of 4,000 tokens, each takes 327,680 times 4,000, or 1.31 GB, so 3.2 GB still holds only about two.

The gap between the last two rows is a business decision. Moving from FP8 on two GPUs to BF16 on four doubles the hardware to preserve precision, and I wouldn’t pay for that unless your evaluation shows FP8 harms the answers you care about. Sizing and model evaluation depend on each other, and the post on choosing an open model treats each quantization as a separate candidate for that reason.

Average context is often far below the maximum, but don’t size on the average alone. Analytics agents can carry big schemas and tool results, and a burst of long requests is exactly what arrives when a morning report goes out. Use your 95th-percentile prompt and output lengths from real traffic, and check the peak separately.

Check the arithmetic against the engine

Your estimate is a hypothesis, and the engine can test it before any load test. vLLM logs a line of the form "Maximum concurrency for 8192 tokens per request" at startup, its own figure calculated from the cache it allocated. Compare that with your number. A large gap means an assumption is wrong, most likely activations or the cache data type. NIM’s list-model-profiles command groups profiles as runnable, low on memory (weights fit but full context does not), or incompatible.

Two settings behave counter-intuitively, according to NVIDIA’s memory guide. Lowering the maximum context limits the size of a request and may not shrink the allocated cache pool. Lowering the memory fraction, set through NIM_KVCACHE_PERCENT, can make a cache-capacity failure worse, though it can help with an out-of-memory error during warm-up. NVIDIA also says no single amount of headroom works for every profile, so treat any rule of thumb with care, including the 2 GB in the example above.

When the cache fills, requests wait or are preempted, and they don’t fail cleanly. PagedAttention, the design behind vLLM, was built to reduce waste in this cache and to share blocks across requests, so capacity can beat a simple per-request sum when prompts share a long prefix. Measure that for your traffic before you count on it.

Load test the service objective

Memory tells you what fits. It can’t tell you how fast anything runs. For that, replay realistic prompts through the whole application path, including authentication, retrieval, tools and validation, because a token-generation benchmark says little about how long a person waits for a usable answer.

Raise concurrency in steps and watch the engine’s own metrics. vLLM exposes vllm:kv_cache_usage_perc, vllm:num_requests_running, vllm:request_queue_time_seconds, vllm:time_to_first_token_seconds and vllm:e2e_request_latency_seconds. Look for the level where queue time starts to climb while cache usage sits near full. Your capacity is there, and it should be above your peak with room to spare. Keep the run going through a restart so you also learn how long a cold start takes to load the model.

Buying decisions the arithmetic leaves open

A few decisions remain after the numbers. One device is a single point of failure, so decide whether an outage stops a workflow people depend on, and whether you need another GPU for redundancy on top of the capacity above. An H100 NVL offers 94 GB per GPU, against 80 GB for SXM, and that difference can move a configuration past a threshold, so rerun the arithmetic on every card you are quoted. Multi-GPU tensor parallelism also ties those GPUs together, which affects what kind of server you need.

Rent before you buy if you can. A week of cloud GPUs running your actual prompts costs little compared with a purchase based on an estimate, and it turns every invented number above into a measured one. Size the pilot and production separately: a pilot can accept a queue that would be intolerable once a team relies on the service.

Bring three business questions

Explore your sources, definitions, and review criteria with our team. Please keep credentials and sensitive records out of the inquiry.