{
  "id": "pytorch/dataloader-worker-segfault",
  "signature": "RuntimeError: DataLoader worker (pid 12345) received signal 11 (Segmentation fault). Possible causes: shared memory exhausted or dataset memory corruption",
  "signature_zh": "运行时错误：DataLoader工作进程（pid 12345）收到信号11（段错误）。可能原因：共享内存耗尽或数据集内存损坏",
  "regex": "RuntimeError: DataLoader worker.*received signal 11",
  "domain": "pytorch",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "A DataLoader worker process crashed with a segmentation fault, typically due to insufficient shared memory (on Linux, /dev/shm is too small) or a buggy dataset that corrupts memory (e.g., unsafe multiprocessing with non-picklable objects).",
  "root_cause_type": "generic",
  "root_cause_zh": "DataLoader工作进程因段错误崩溃，通常由于共享内存不足（Linux上/dev/shm太小）或数据集存在内存损坏错误（例如使用不可pickle对象的不安全多进程）。",
  "versions": [
    {
      "version": "pytorch>=1.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "torchvision>=0.14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "cuda>=11.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "python>=3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing num_workers to speed up data loading",
      "why_fails": "More workers consume more shared memory, making the segfault more likely.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using pin_memory=True without increasing shared memory",
      "why_fails": "Pin memory also uses shared memory, exacerbating the exhaustion.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase shared memory size: In Docker, add --shm-size=8g; on bare metal, remount /dev/shm with larger size: sudo mount -o remount,size=8G /dev/shm",
      "success_rate": 0.9,
      "how": "Increase shared memory size: In Docker, add --shm-size=8g; on bare metal, remount /dev/shm with larger size: sudo mount -o remount,size=8G /dev/shm",
      "condition": "",
      "sources": []
    },
    {
      "action": "Reduce num_workers to 0 or 1 to avoid multiprocessing issues: DataLoader(..., num_workers=0)",
      "success_rate": 0.8,
      "how": "Reduce num_workers to 0 or 1 to avoid multiprocessing issues: DataLoader(..., num_workers=0)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Switch multiprocessing context to 'spawn' (instead of 'fork'): torch.multiprocessing.set_start_method('spawn', force=True)",
      "success_rate": 0.75,
      "how": "Switch multiprocessing context to 'spawn' (instead of 'fork'): torch.multiprocessing.set_start_method('spawn', force=True)",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase shared memory size: In Docker, add --shm-size=8g; on bare metal, remount /dev/shm with larger size: sudo mount -o remount,size=8G /dev/shm",
    "Reduce num_workers to 0 or 1 to avoid multiprocessing issues: DataLoader(..., num_workers=0)",
    "Switch multiprocessing context to 'spawn' (instead of 'fork'): torch.multiprocessing.set_start_method('spawn', force=True)"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pytorch.org/docs/stable/data.html#multi-process-data-loading",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "partial",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}