pytorch
system_error
ai_generated
partial
RuntimeError: DataLoader worker (pid 12345) received signal 11 (Segmentation fault). Possible causes: shared memory exhausted
ID: pytorch/dataloader-worker-segfault-shared-memory
75%Fix Rate
82%Confidence
1Evidence
2024-07-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| pytorch>=1.10.0 | active | — | — | — |
| linux | active | — | — | — |
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.
generic中文
共享内存(/dev/shm)已满或太小,无法容纳 DataLoader 工作进程传输的数据,通常由于批量大小过大或高分辨率图像。
Official Documentation
https://pytorch.org/docs/stable/data.html#multi-process-data-loadingWorkarounds
-
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.
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.
-
80% success Reduce the batch size or use pin_memory=False in DataLoader to avoid copying tensors to pinned memory, which uses shared memory.
Reduce the batch size or use pin_memory=False in DataLoader to avoid copying tensors to pinned memory, which uses shared memory.
中文步骤
通过重新挂载增加 /dev/shm 的大小。在 Docker 中使用 --shm-size=8g。在裸机上编辑 /etc/fstab 或使用 mount -o remount,size=8G /dev/shm。
减少批量大小或在 DataLoader 中使用 pin_memory=False,避免将张量复制到固定内存,这使用共享内存。
Dead Ends
Common approaches that don't work:
-
40% fail
This is a workaround that changes behavior, but it doesn't fix the underlying shared memory limit.
-
90% fail
Larger batches increase shared memory usage, exacerbating the issue.
-
70% fail
Shared memory is recreated at boot, but the limit remains the same; it will fill up again.