{
  "id": "pytorch/data-loader-worker-segfault-shared-memory",
  "signature": "RuntimeError: DataLoader worker (pid 12345) received signal 11 (Segmentation fault). Possible causes: shared memory exhaustion, insufficient shared memory, or too many workers.",
  "signature_zh": "运行时错误：DataLoader工作进程（pid 12345）收到信号11（段错误）。可能原因：共享内存耗尽、共享内存不足或工作进程过多。",
  "regex": "DataLoader worker \\(pid \\d+\\) received signal 11 \\(Segmentation fault\\)",
  "domain": "pytorch",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "DataLoader worker processes exhaust the system's shared memory (/dev/shm) limit, causing a segmentation fault when trying to copy tensors from shared memory to the GPU.",
  "root_cause_type": "generic",
  "root_cause_zh": "DataLoader工作进程耗尽系统共享内存（/dev/shm）限制，在尝试将张量从共享内存复制到GPU时导致段错误。",
  "versions": [
    {
      "version": "pytorch>=1.8.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "linux>=4.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "cuda>=11.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reduce the batch size to lower memory pressure.",
      "why_fails": "Reducing batch size does not directly affect shared memory usage per worker; each worker still allocates its own copy of tensors in shared memory for pin_memory.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase the number of DataLoader workers to speed up data loading.",
      "why_fails": "Increasing the number of workers exacerbates shared memory exhaustion by spawning more processes that each allocate their own shared memory buffers.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Increase the system shared memory limit by running the container or process with `--shm-size=8g` (Docker) or `mount -o remount,size=8G /dev/shm` (host). Alternatively, set `DataLoader(pin_memory=False, num_workers=0)` to bypass shared memory entirely.",
      "success_rate": 0.9,
      "how": "Increase the system shared memory limit by running the container or process with `--shm-size=8g` (Docker) or `mount -o remount,size=8G /dev/shm` (host). Alternatively, set `DataLoader(pin_memory=False, num_workers=0)` to bypass shared memory entirely.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `torch.utils.data.DataLoader(..., multiprocessing_context='spawn')` to force the spawn start method, which may reduce shared memory fragmentation on some systems.",
      "success_rate": 0.75,
      "how": "Use `torch.utils.data.DataLoader(..., multiprocessing_context='spawn')` to force the spawn start method, which may reduce shared memory fragmentation on some systems.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Increase the system shared memory limit by running the container or process with `--shm-size=8g` (Docker) or `mount -o remount,size=8G /dev/shm` (host). Alternatively, set `DataLoader(pin_memory=False, num_workers=0)` to bypass shared memory entirely.",
    "Use `torch.utils.data.DataLoader(..., multiprocessing_context='spawn')` to force the spawn start method, which may reduce shared memory fragmentation on some systems."
  ],
  "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.87,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-02-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}