tensorflow-GPUを用いてkerasによる機械学習時にmodel.fitを行うと以下のエラーが出現するのですが、GPUのメモリに学習時にデータが乗り切らないということでしょうか?
GPUをオフにして学習を開始するとエラーは出現しておりません。
GPU:GTX1060 3GBを使用しております。
学習させたいデータサイズは以下です。
train_X.shape:(4732,270)
train_y.shape:(4732,5)
test_X.shape:(2028,270)
test_y.shape:(2028,5)
batch_size,epochsを増やして学習させたいのですが、増やしていくと頻繁にエラーが出現してしまいます。
python
1#入力層、中間層、出力層の設定 2model=Sequential() 3model.add(Dense(units=4700,activation="relu",kernel_regularizer=regularizers.l2(0.001),input_shape=(n_features,))) 4model.add(normalization.BatchNormalization()) 5#Dropoutを設定 6model.add(Dense(units=4700,activation="relu",kernel_regularizer=regularizers.l2(0.001))) 7model.add(Dropout(0.5)) 8model.add(Dense(units=2700,activation="relu",kernel_regularizer=regularizers.l2(0.001))) 9model.add(Dropout(0.5)) 10model.add(Dense(units=1300,activation="relu",kernel_regularizer=regularizers.l2(0.001))) 11model.add(Dropout(0.5)) 12model.add(Dense(units=700,activation="relu",kernel_regularizer=regularizers.l2(0.001))) 13model.add(Dense(units=n_classes,activation="sigmoid")) 14model.compile(loss="binary_crossentropy",optimizer="adam",metrics=["accuracy"]) 15history=model.fit(train_X,train_y,epochs=1000,validation_data=(test_X,test_y),batch_size=2000,verbose=1,shuffle=True) 16 17 18#以下エラー内容: 19 20ResourceExhaustedError: OOM when allocating tensor with shape[4732,2716] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc 21 [[Node: dense_13/weight_regularizer/Square = Square[T=DT_FLOAT, _class=["loc:@training_1/Adam/gradients/AddN_15"], _device="/job:localhost/replica:0/task:0/device:GPU:0"](dense_13/kernel/read)]] 22Hint: 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. 23 [[Node: metrics_1/acc/Mean_1/_743 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_2321_metrics_1/acc/Mean_1", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]] 24Hint: 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. 25 26
以上のエラーが出ると再起動しなくては学習がすすまない状態になってしまいます。
このエラーを回避する良い方法はありますでしょうか。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/03 16:37
2018/10/03 16:43
2018/10/03 16:45
2018/10/03 16:50
2018/10/03 17:00