報錯: 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

       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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章