解决GPU/Ascend内存不够用,GPU:Memory not enough/Ascend:Out of Memory

一.  运行环境

MindSpore版本号:1.0.0;

 

硬件平台:GPU;

 

Python版本号:3.7.5;

 

操作系统:linux Ubuntu

 

 

二.  脚本信息

 

下载https://gitee.com/mindspore/mindspore.git仓库,修改model_zoo/official/cv/retinaface_resnet50/src/config.py中的batch_size为32,测试对不同batch_size的支持以及上限。

运行model_zoo/official/cv/retinaface_resnet50/单P和多P脚本。

单P运行成功,多P报错(单P目前有内存换入换出功能的支持,可以跑更大的batch_size)。

 

 

三.  报错信息

image.png

 

四.  解决方法

 

减小batch_size为16,多P脚本能够正常运行。

 

五.  总结

 

会导致device 内存不够用的场景:1、batch_size过大;2、模型过大;3、输入的数据shape太大;4、引入异常大的parameter等都会造成device内存不够用。

在Ascend上报错稍微有区别:Ascend平台上device内存不足时出现的报错:Out of Memory!!! total[3212254720] (dynamic[0] memory poll[524288000]) malloc[32611480064] failed! 

posted @ 2021-12-30 18:38  MS小白  阅读(82)  评论(0)    收藏  举报