keep-loving-pythonのブログ

Pythonを愛し続けたいです(Pythonが流行っている限りですが。。。)

解決策。tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape

解決策。tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape

環境

windows10 python3.7.2 GPUなしpc

エラー

tensorflow.python.framework.errors_impl.ResourceExhaustedError:  OOM when allocating tensor with shape[32,128,768] and type float on /job:localhost/replica:0/task:0/device:CPU:0 by allocator cpu
         [[{{node functional_1/keras_layer/StatefulPartitionedCall/StatefulPartitionedCall/StatefulPartitionedCall/transformer_encoder/StatefulPartitionedCall/transformer/layer_3/output_layer_norm/batchnorm/mul_1}}]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
 [Op:__inference_train_function_42425]

対象プログラム

https://github.com/shrikantnaidu/BERT-for-Text-Classification-with-TensorFlow Fine_Tune_BERT_for_Text_Classification_with_TensorFlow.ipynbをpyファイルに変換

解決策

メモリ不足でした。 batchサイズを小さくして、回避いたしました。

コメント

「tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM 」のときは、参考にして下さい。