Why am I getting ResourceExhaustedError: OOM when allocating tensor with shape[24,64,1024,1024] when my batch size is 1?

Why am I getting ResourceExhaustedError: OOM when allocating tensor with shape[24,64,1024,1024] when my batch size is 1?

我的模型总结:

Total params: 932,225
Trainable params: 928,897
Non-trainable params: 3,328

我正在使用 loss="binary_crossentropy"、优化器="sgd" 和 batch_size=1 用于 binary class 语义分割.

241024x1024x3训练图像的总数,64是深度第一个转换层。

注意:我正在使用 google colab gpu 运行时。

我将 steps_per_epoch 传递给 model.fit 而不是 batch_size在这种情况下也不需要,

H = model.fit(X_train, Y_train, validation_data=(X_valid, Y_valid),
              steps_per_epoch=len(X_train)//BATCHSIZE, epochs=EPOCHS,
              validation_steps=len(X_valid)//BATCHSIZE)

steps_per_epoch 替换为 batch_size 以某种方式解决了我的问题。

H = model.fit(X_train, Y_train, batch_size=BATCHSIZE,
              epochs=EPOCHS, validation_data=(X_valid, Y_valid))