# RuntimeError: DataLoader worker (pid 12345) received signal 11 (Segmentation fault). Possible causes: shared memory exhausted

- **ID:** `pytorch/dataloader-worker-segfault-shared-memory`
- **Domain:** pytorch
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

The shared memory (/dev/shm) is full or too small to accommodate the data being transferred from DataLoader workers, often due to large batch sizes or high-resolution images.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| pytorch>=1.10.0 | active | — | — |
| linux | active | — | — |

## Workarounds

1. **Increase the size of /dev/shm by remounting with a larger size. In Docker, use --shm-size=8g. On bare metal, edit /etc/fstab or use mount -o remount,size=8G /dev/shm.** (90% success)
   ```
   Increase the size of /dev/shm by remounting with a larger size. In Docker, use --shm-size=8g. On bare metal, edit /etc/fstab or use mount -o remount,size=8G /dev/shm.
   ```
2. **Reduce the batch size or use pin_memory=False in DataLoader to avoid copying tensors to pinned memory, which uses shared memory.** (80% success)
   ```
   Reduce the batch size or use pin_memory=False in DataLoader to avoid copying tensors to pinned memory, which uses shared memory.
   ```

## Dead Ends

- **** — This is a workaround that changes behavior, but it doesn't fix the underlying shared memory limit. (40% fail)
- **** — Larger batches increase shared memory usage, exacerbating the issue. (90% fail)
- **** — Shared memory is recreated at boot, but the limit remains the same; it will fill up again. (70% fail)
