llm
resource_error
ai_generated
true
RuntimeError: 内存不足错误:无法为KV缓存块分配内存。请求块大小:16,空闲块:0
RuntimeError: OutOfMemoryError: Unable to allocate memory for KV cache block. Requested block size: 16, free blocks: 0
ID: llm/vllm-block-manager-out-of-memory
80%修复率
85%置信度
1证据数
2024-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| vLLM 0.3.0 | active | — | — | — |
| vLLM 0.4.0 | active | — | — | — |
| vLLM 0.4.2 | active | — | — | — |
| CUDA 12.1 | active | — | — | — |
| CUDA 12.2 | active | — | — | — |
根因分析
vLLM的PagedAttention块管理器因gpu_memory_utilization设置不足或并发请求超出内存预算,耗尽了KV缓存块的所有可用GPU内存。
English
vLLM's PagedAttention block manager exhausts all available GPU memory for KV cache blocks due to insufficient gpu_memory_utilization setting or concurrent requests exceeding memory budget.
官方文档
https://vllm.readthedocs.io/en/latest/models/engine_args.html解决方案
-
将gpu_memory_utilization降低到0.85或更低,并适当设置--max-num-seqs: python -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --gpu-memory-utilization 0.80 --max-num-seqs 64
-
通过--swap-space启用交换空间,在GPU内存紧张时将KV缓存卸载到CPU: python -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --swap-space 16
无效尝试
常见但无效的做法:
-
60% 失败
Larger batch tokens consume more KV cache memory without freeing space; the error persists or worsens.
-
40% 失败
Truncates all inputs, degrading model quality for long-context tasks; may still OOM if concurrent requests are high.