# Dataloader with num\_workers\>1 hangs every epoch

**URL:** <https://discuss.pytorch.org/t/dataloader-with-num-workers-1-hangs-every-epoch/20323>\
**Category:** Uncategorized\
**Created:** [June 27, 2018, 5:52am UTC](https://discuss.pytorch.org/t/dataloader-with-num-workers-1-hangs-every-epoch/20323 "2018-06-27T05:52:41Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [October 25, 2018, 9:40pm UTC](https://discuss.pytorch.org/t/dataloader-with-num-workers-1-hangs-every-epoch/20323/16 "2018-10-25T21:40:32Z")

</div>

Good to hear it was this issue!  
Well, it might sound a bit weird, but it’s the default mechanism using multiprocessing.  
In case you are lazily loading your data it’s not a big deal.

However, if you preload the data, this might cause an issue.  
Generally I’m not sure, if you get a big performance improvement using multiple workers, if the data is already loaded.

That being said, you could use shared memory, which would do exactly as you’ve suggested.  
I’ve created a small example yesterday for exactly this use case [here](https://discuss.pytorch.org/t/dataloader-resets-dataset-state/27960/4?u=ptrblck). Maybe you could use it as well?

---

_[View the full topic](https://discuss.pytorch.org/t/dataloader-with-num-workers-1-hangs-every-epoch/20323)._
