# RuntimeError: DataLoader worker (pid 12345) exited unexpectedly: Bus error (core dumped)

- **ID:** `pytorch/dataloader-worker-exit-with-bus-error`
- **Domain:** pytorch
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 78%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| torch>=1.12.0 | active | — | — |
| cuda>=11.0 | active | — | — |
| python>=3.8 | active | — | — |

## Workarounds

1. **Set multiprocessing start method to 'spawn' instead of 'fork' to avoid shared memory corruption.** (85% success)
   ```
   Set multiprocessing start method to 'spawn' instead of 'fork' to avoid shared memory corruption.
   ```
2. **Reduce DataLoader batch size or use prefetch_factor=2 to limit shared memory usage.** (75% success)
   ```
   Reduce DataLoader batch size or use prefetch_factor=2 to limit shared memory usage.
   ```

## Dead Ends

- **Increasing the number of workers in DataLoader** — More workers increase contention for shared memory and can exacerbate the bus error. (90% fail)
- **Setting pin_memory=False in DataLoader** — Bus errors are not primarily caused by pin_memory; disabling it may not address the underlying memory alignment issue. (80% fail)
