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

其他格式: JSON · Markdown 中文 · English
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.

generic

官方文档

https://vllm.readthedocs.io/en/latest/models/engine_args.html

解决方案

  1. 将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
  2. 通过--swap-space启用交换空间,在GPU内存紧张时将KV缓存卸载到CPU:
    
    python -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --swap-space 16

无效尝试

常见但无效的做法:

  1. 60% 失败

    Larger batch tokens consume more KV cache memory without freeing space; the error persists or worsens.

  2. 40% 失败

    Truncates all inputs, degrading model quality for long-context tasks; may still OOM if concurrent requests are high.