Why your vLLM server runs out of memory, and the settings that fix it
vLLM fails at startup when the KV cache does not fit: 'No available memory for the cache blocks' or 'KV cache is needed, which is larger than the available KV cache memory'. Read which error you got, then lower --max-model-len (or set it to auto), lower --max-num-seqs, use an FP8 KV cache, or split the model over more GPUs. Checked against vLLM 0.34.0, 23 November 2026.
Lium team7 min read
vllm
llm-inference
troubleshooting
kv-cache

Short answer: vLLM runs out of memory when the model weights plus the KV cache for your longest request do not fit on the GPU. The error message tells you which case you hit and the largest context that would fit. Fix it in this order:
- Lower
--max-model-len, or set it toautoso vLLM picks the longest context that fits. - Lower
--max-num-seqsso fewer requests share the cache at once. - Store the KV cache in FP8 with
--kv-cache-dtype fp8, which halves it compared with BF16. - If the weights themselves barely fit, use a quantized model, split it over GPUs with
--tensor-parallel-size, or move to a card with more memory.
Everything below is checked against the vLLM 0.34.0 source (released 16 November 2026) and the vLLM conserving memory guide, both read 23 November 2026.
Why vLLM needs so much memory
vLLM loads the model weights, runs a warmup pass, and then gives the memory that is left to the KV cache. The KV cache holds the keys and values of every token in every running request, so it grows with context length and with the number of requests in flight.
Per token, the KV cache costs 2 (one key, one value) x layers x KV heads x head size x bytes per value. Take Qwen3-8B, whose
config.json lists 36 layers, 8 KV heads and a head size of 128 (read 23 November 2026):- KV per token in BF16: 2 x 36 x 8 x 128 x 2 bytes = 147,456 bytes, about 144 KiB.
- One request at the full 40,960-token context: about 5.6 GiB of KV cache.
- Weights in BF16: 8.19 billion parameters x 2 bytes, about 16.4 GB.
On a 24 GB RTX 4090, the weights alone take most of the card. A single full-context request then needs more KV cache than is left, and vLLM refuses to start. That is our arithmetic from the numbers above. vLLM measures the real free memory on your card and prints it in the error.
The two startup errors and what they mean
vLLM checks the KV cache before it serves anything. In 0.34.0 the check lives in
vllm/v1/core/kv_cache_planning.py and raises one of two errors."No available memory for the cache blocks." Nothing at all is left for the KV cache after the weights and warmup. The context length is not the problem. First check
--gpu-memory-utilization: if you set it low, vLLM may use too little of the card to leave any room for the cache, and raising it (fix 4) is the whole fix. If it is already high, the weights, activations or CUDA graphs fill the card. Go to the weights fixes below: a quantized model, more GPUs, or a bigger card."To serve at least one request with the model's max seq len (X), (Y GiB KV cache is needed, which is larger than the available KV cache memory (Z GiB)." The model loads, but one request at your context length does not fit. The same message continues with "Based on the available memory, the estimated maximum model length is W." Use W: start again with
--max-model-len at or below it, or let vLLM choose with --max-model-len auto.Both messages end with a hint and a link to the conserving memory guide. The hint depends on how vLLM sized the cache, which the next section explains.
Fix 1: cap the context with --max-model-len
If you do not set
--max-model-len, vLLM uses the model's full context from its config. For Qwen3-8B that is 40,960 tokens. Most chat and RAG traffic never comes close, so cap it:bash
vllm serve Qwen/Qwen3-8B --max-model-len 16kThe flag accepts
k suffixes: 16k is 16,000 tokens and 16K is 16,384. Set it to auto (or -1) and vLLM uses the model's full context if it fits, otherwise the largest length that does. It logs the length it picked, and it warns you when the result is below 8,192 tokens. Requests longer than the cap are rejected, so pick a value that covers your real prompts plus outputs.Fix 2: serve fewer requests at once with --max-num-seqs
--max-num-seqs caps how many requests the scheduler runs in one batch. The KV cache has to hold the tokens of all of them, so a lower cap needs less cache at the cost of throughput under load. The conserving memory guide pairs it with a lower max_model_len for small GPUs:bash
vllm serve Qwen/Qwen3-8B --max-model-len 8k --max-num-seqs 16Its default depends on the hardware and how you run vLLM, so read the value from the startup log before you change it.
Fix 3: store the KV cache in FP8
--kv-cache-dtype fp8 stores keys and values in one byte instead of two. That halves the cache: Qwen3-8B drops from about 144 KiB to about 72 KiB per token, so the same memory holds twice the tokens. The other accepted values in 0.34.0 include auto (same as the model), bfloat16, fp8_e4m3 and fp8_e5m2.bash
vllm serve Qwen/Qwen3-8B --max-model-len 32k --kv-cache-dtype fp8FP8 KV can cost a little accuracy. Run your own evaluation prompts before and after.
Fix 4: give the cache more of the card
In 0.34.0,
--gpu-memory-utilization is the share of GPU memory vLLM may use. If you leave it unset, it is 1.0 with the extensible KV cache and 0.92 without it. The extensible KV cache is on by default on CUDA and ROCm. It sizes the cache from the memory that is actually free after CUDA graph capture, instead of from an estimate.That changes the hint at the end of the error:
- Extensible KV cache, utilization below 1.0: "increase it (with the extensible KV cache it defaults to 1.0) or decrease
max_model_lenormax_num_seqs". If you set a lower value yourself, raise it, or remove the flag. - Extensible KV cache already at 1.0: "The extensible KV cache already takes all device memory left after the model and its activations; decrease
max_model_lenormax_num_seqs, or the model needs a device with more memory." Raising utilization cannot help here. Use fixes 1 to 3, or the weights fixes below. - Without the extensible cache: "Try increasing
gpu_memory_utilization". Raise it a step, for example to 0.95, if nothing else runs on the GPU.
CUDA graphs speed up decoding, but they take memory too. If the error mentions CUDA graph capture and warmup, capture fewer sizes with
cudagraph_capture_sizes in the compilation config, or turn graphs off with --enforce-eager. Eager mode frees memory but makes each token slower.When the weights do not fit
If you get "No available memory for the cache blocks", or a
torch.OutOfMemoryError: CUDA out of memory while the model loads, check --gpu-memory-utilization first, as fix 4 describes: a low value can leave no room for the cache on a card that would fit the model. If it is already high, the weights plus activations are too big for the card. Context settings cannot fix that. You have three ways out:- Quantize the weights. An FP8 checkpoint takes about half the memory of BF16, and a 4-bit checkpoint (AWQ or GPTQ) about a quarter. vLLM reads the method from the model's config.
- Split the model over GPUs with
--tensor-parallel-size 2(or 4, or 8) on a multi-GPU node. Each GPU holds a slice of the weights and of the KV cache. - Use a card with more memory. For the same model, more VRAM leaves more room for the KV cache, which means longer contexts and more requests at once.
For multimodal models, also cap the images or videos per prompt with
--limit-mm-per-prompt, because vLLM reserves memory for the largest inputs the model accepts.Picking a card on Lium
Lium lists the memory of each card, so you can match the fix to the hardware:
- RTX 4090, 24 GB: 7B to 8B models in BF16 with a capped context, or larger ones quantized.
- RTX 5090, 32 GB: the same models with more room left for the KV cache.
- H100, 80 GB: 30B-class models in BF16, or a 70B model in FP8 across two cards.
- H200, 141 GB: a 70B model in FP8 on one card, with room for long contexts.
These follow from each card's memory and the weights math above. Check the live supply and asks on lium.io/stats and lium.io/pricing.
To try the fixes on a real server, follow Serve an open LLM with vLLM on a single Lium GPU. It starts an RTX 4090 pod with
lium up --gpu RTX4090 and runs vllm serve with --max-model-len 8192, which is fix 1 in practice. Pods bill by the second, so a failed start costs you only the minutes it ran.Checklist
- Read the error: "No available memory for the cache blocks" means the weights do not fit, or
--gpu-memory-utilizationis set too low. "KV cache is needed" means the context does not fit. - Use the "estimated maximum model length" from the error, or set
--max-model-len auto. - Lower
--max-num-seqsif you can trade throughput for memory. - Add
--kv-cache-dtype fp8to fit twice the tokens. - Check the hint about
gpu_memory_utilizationand CUDA graphs. - Still out of memory: quantize, use
--tensor-parallel-size, or pick a card with more memory.
Run it on Lium
Get new posts by e-mail: Subscribe to the Lium newsletter


