{
  "id": "pytorch/dataloader-queue-timeout",
  "signature": "RuntimeError: DataLoader worker (pid 12345) timed out after 300 seconds waiting for data from queue. Consider increasing timeout or reducing batch size.",
  "signature_zh": "运行时错误：DataLoader 工作进程（pid 12345）在等待队列数据 300 秒后超时。考虑增加超时时间或减小批次大小。",
  "regex": "RuntimeError: DataLoader worker \\(pid \\d+\\) timed out after \\d+ seconds waiting for data from queue",
  "domain": "pytorch",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "DataLoader worker processes are stuck waiting for data from the prefetch queue, typically due to slow data loading, deadlock in custom dataset, or insufficient shared memory.",
  "root_cause_type": "generic",
  "root_cause_zh": "DataLoader 工作进程在等待预取队列数据时卡住，通常是由于数据加载慢、自定义数据集中的死锁或共享内存不足。",
  "versions": [
    {
      "version": "torch>=1.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "torch<=2.5.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing the number of workers to speed up loading",
      "why_fails": "More workers can exacerbate shared memory contention and lead to more timeouts, especially if the bottleneck is I/O or CPU.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting timeout=0 to disable timeout",
      "why_fails": "Setting timeout=0 means no timeout, but the worker may hang indefinitely, causing the training to stall.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the timeout parameter in DataLoader. For example: DataLoader(dataset, batch_size=32, num_workers=4, timeout=600) to allow up to 600 seconds.",
      "success_rate": 0.85,
      "how": "Increase the timeout parameter in DataLoader. For example: DataLoader(dataset, batch_size=32, num_workers=4, timeout=600) to allow up to 600 seconds.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce batch size or number of workers to lower memory and I/O pressure. For example: DataLoader(dataset, batch_size=16, num_workers=2)",
      "success_rate": 0.9,
      "how": "Reduce batch size or number of workers to lower memory and I/O pressure. For example: DataLoader(dataset, batch_size=16, num_workers=2)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use prefetch_factor=1 in DataLoader to reduce prefetch queue size: DataLoader(dataset, batch_size=32, num_workers=4, prefetch_factor=1)",
      "success_rate": 0.75,
      "how": "Use prefetch_factor=1 in DataLoader to reduce prefetch queue size: DataLoader(dataset, batch_size=32, num_workers=4, prefetch_factor=1)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase the timeout parameter in DataLoader. For example: DataLoader(dataset, batch_size=32, num_workers=4, timeout=600) to allow up to 600 seconds.",
    "Reduce batch size or number of workers to lower memory and I/O pressure. For example: DataLoader(dataset, batch_size=16, num_workers=2)",
    "Use prefetch_factor=1 in DataLoader to reduce prefetch queue size: DataLoader(dataset, batch_size=32, num_workers=4, prefetch_factor=1)"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-06-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}