栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memor

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memor

在Docker容器中利用Pytorch训练模型的时候,出现了题目中的错误:

ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm).
ERROR: Unexpected bus error encountered in worker. This might be caused by insufficient shared memory (shm).
......
RuntimeError: unable to write to file : No space left on device (28)

看错误提示应该是共享内存不够了。

在容器红执行df -h查看磁盘使用情况:

可见容器默认的shared memory只有64MB。但训练程序中,data_loader设置的workers数目比较多,该程序中为8,这些workers通过共享内存进行协作,导致默认的共享内存不够用。

Please note that PyTorch uses shared memory to share data between processes, so if torch multiprocessing is used (e.g. for multithreaded data loaders) the default shared memory segment size that container runs with is not enough, and you should increase shared memory size either with --ipc=host or --shm-size command line options to nvidia-docker run.

基于以上原因,解决方法可从两个方面入手:

1. 将workers数量降低,例如设置num_workers=0;

2. 将容器的共享内存加大,由上面英文提示,可通过--ipc=host或--shm-size进行设置。 

这里,我选择的是第二种方式,加大容器的共享内存:

docker rum ... --shm-size 8G ...

重启容器后,再次通过df -h查看磁盘使用情况,发现共享内存已经变成8G:

再次运行训练程序,成功! 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/865101.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号