# 运行时错误：数据加载器工作进程（pid 12345）意外退出：总线错误（核心已转储）

- **ID:** `pytorch/dataloader-worker-exit-with-bus-error`
- **领域:** pytorch
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 78%

## 根因

数据加载器工作进程因共享内存损坏或对齐问题遇到总线错误，通常由共享内存中不兼容对齐的大张量引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| torch>=1.12.0 | active | — | — |
| cuda>=11.0 | active | — | — |
| python>=3.8 | active | — | — |

## 解决方案

1. ```
   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.
   ```

## 无效尝试

- **Increasing the number of workers in DataLoader** — More workers increase contention for shared memory and can exacerbate the bus error. (90% 失败率)
- **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% 失败率)
