pytorch
system_error
ai_generated
partial
RuntimeError: DataLoader worker (pid 12345) exited unexpectedly: Bus error (core dumped)
ID: pytorch/dataloader-worker-exit-with-bus-error
78%Fix Rate
83%Confidence
1Evidence
2024-02-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| torch>=1.12.0 | active | — | — | — |
| cuda>=11.0 | active | — | — | — |
| python>=3.8 | active | — | — | — |
Root Cause
DataLoader worker process encountered a bus error due to shared memory corruption or misalignment, often caused by large tensors in shared memory with incompatible alignment.
generic中文
数据加载器工作进程因共享内存损坏或对齐问题遇到总线错误,通常由共享内存中不兼容对齐的大张量引起。
Official Documentation
https://pytorch.org/docs/stable/data.html#multi-process-data-loadingWorkarounds
-
85% success Set multiprocessing start method to 'spawn' instead of 'fork' to avoid shared memory corruption.
Set multiprocessing start method to 'spawn' instead of 'fork' to avoid shared memory corruption.
-
75% success Reduce DataLoader batch size or use prefetch_factor=2 to limit shared memory usage.
Reduce DataLoader batch size or use prefetch_factor=2 to limit shared memory usage.
中文步骤
Set multiprocessing start method to 'spawn' instead of 'fork' to avoid shared memory corruption.
Reduce DataLoader batch size or use prefetch_factor=2 to limit shared memory usage.
Dead Ends
Common approaches that don't work:
-
Increasing the number of workers in DataLoader
90% fail
More workers increase contention for shared memory and can exacerbate the bus error.
-
Setting pin_memory=False in DataLoader
80% fail
Bus errors are not primarily caused by pin_memory; disabling it may not address the underlying memory alignment issue.