# ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm)

**URL:** <https://discuss.pytorch.org/t/error-unexpected-bus-error-encountered-in-worker-this-might-be-caused-by-insufficient-shared-memory-shm/38719>\
**Category:** vision\
**Created:** [March 2, 2019, 10:49am UTC](https://discuss.pytorch.org/t/error-unexpected-bus-error-encountered-in-worker-this-might-be-caused-by-insufficient-shared-memory-shm/38719 "2019-03-02T10:49:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yue\_Johnson](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/y/aeb1de/32.png) [@Yue\_Johnson](https://discuss.pytorch.org/u/Yue_Johnson)\
**Post date:** [March 2, 2019, 10:49am UTC](https://discuss.pytorch.org/t/error-unexpected-bus-error-encountered-in-worker-this-might-be-caused-by-insufficient-shared-memory-shm/38719/1 "2019-03-02T10:49:00Z")

</div>

Hi, guys , I’m occur a error which is “**ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm)**”

I run my code in local machine , not in docker !! not in docker !! not in docker!

GPU : GTX 1080ti with 12G memory  
RAM : 32G  
CPU: intel 9700K  
Pytorch version : 0.4.1 or 1.0.1 all test  
python version: 3.5  
DATA API:  
1) torch.utils.data.Dataset class  
2) torch.utils.data.DataLoader class and **num\_works=12**

When I train my code with those config, I have never seen this error before .  
my dataset is many jpg format image, So I use Dataset. **getitem** () implement some function such as , load image data from file into numpy.array by using opencv-python and convert it to Tensor .  
When num\_works=0 , this pipeline is very slow and only one thread of cpu for working.  
When num\_works=12, all threads of cpu for working it is very good , but this pipeline is still slow for first two epochs and fast for next epochs, and my RAM nearly full , I think it should load data into RAM first, then train them.

But now it out many error as this Topic,

 ![image](https://discuss.pytorch.org/uploads/default/original/2X/d/d78043ddb7757d6d2da1cd3c8f3ef1544065aa7f.png)  
_iter\_t_ it mean how many seconds for one step, it very very slow, Usually it is smaller than 1

My questions:

1. how I fix this error
2. how to speed up dataload pipeline ??? ( I have already using data.Dataset and data.DataLoader API with num\_workers=12)

my code is here:  
because I’m newbee, so I can only upload one picture…
