{
  "id": "llm/vllm-block-manager-out-of-memory",
  "signature": "RuntimeError: OutOfMemoryError: Unable to allocate memory for KV cache block. Requested block size: 16, free blocks: 0",
  "signature_zh": "RuntimeError: 内存不足错误：无法为KV缓存块分配内存。请求块大小：16，空闲块：0",
  "regex": "RuntimeError: OutOfMemoryError: Unable to allocate memory for KV cache block",
  "domain": "llm",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "vLLM的PagedAttention块管理器因gpu_memory_utilization设置不足或并发请求超出内存预算，耗尽了KV缓存块的所有可用GPU内存。",
  "versions": [
    {
      "version": "vLLM 0.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "vLLM 0.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "vLLM 0.4.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CUDA 12.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "CUDA 12.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Larger batch tokens consume more KV cache memory without freeing space; the error persists or worsens.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Truncates all inputs, degrading model quality for long-context tasks; may still OOM if concurrent requests are high.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Reduce gpu_memory_utilization to 0.85 or lower and set --max-num-seqs appropriately:\n\npython -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --gpu-memory-utilization 0.80 --max-num-seqs 64",
      "success_rate": 0.9,
      "how": "Reduce gpu_memory_utilization to 0.85 or lower and set --max-num-seqs appropriately:\n\npython -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --gpu-memory-utilization 0.80 --max-num-seqs 64",
      "condition": "",
      "sources": []
    },
    {
      "action": "Enable swap space via --swap-space to offload KV cache to CPU when GPU memory is tight:\n\npython -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --swap-space 16",
      "success_rate": 0.85,
      "how": "Enable swap space via --swap-space to offload KV cache to CPU when GPU memory is tight:\n\npython -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --swap-space 16",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将gpu_memory_utilization降低到0.85或更低，并适当设置--max-num-seqs：\n\npython -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：\n\npython -m vllm.entrypoints.openai.api_server --model meta-llama/Llama-2-7b-hf --swap-space 16"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://vllm.readthedocs.io/en/latest/models/engine_args.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}