报错: ResourceExhaustedError:OOM when allocating tensor of shape [21128,768] and type float

报错: ResourceExhaustedError:OOM when allocating tensor of shape [21128,768] and type float

今天跑bert分类训练的时候遇到的bug

我的bert分类项目地址(有数据,本地win10可运行):https://github.com/yongzhuo/bert

参考的是 小数据福音!BERT在极小数据下带来显著提升的开源实现

              这个网址: http://www.sohu.com/a/278070440_500659

过程:

1.按照它的方式处理数据,开始时候跑的是20万+的数据,报错OOM

2.首先是调小batch_size,直至2还是报错,哭。再调小max_seq_length=50,还是不行,哭

3.查了一些资料,

        1.ResourceExhaustedError (see above for traceback): OOM when allocating tensor

         地址:https://github.com/google-research/bert/issues/118

扫描二维码关注公众号,回复: 5516120 查看本文章

       2.ResourceExhaustedError:OOM when allocating tensor of shape [3840,4096] and type float (Out of memory Issue)

        地址:https://stackoverflow.com/questions/44971481/resourceexhaustederroroom-when-allocating-tensor-of-shape-3840-4096-and-type

        还是没有解决,但了解到是存储不够的原因了。

4.想把TPUEstimator改为Estimator,因为显卡存储不够,但内存是有16G的,改成CPU运行就好了;可惜水平不够,改不了

5.怎么办呢,让TPUEstimator运行cpu不就行了,于是增加

os.environ["CUDA_VISIBLE_DEVICES"] = "2,3"#没法取到显卡gpu,就走cpu了(猜测)

6.问题解决

我的bert分类项目地址(有数据,本地win10可运行):https://github.com/yongzhuo/bert

猜你喜欢

转载自blog.csdn.net/rensihui/article/details/86215882
今日推荐