【问题标题】:GPUs out of memory even in reading small data? Using "Quadro m1000m 4GB GPU"GPU即使在读取小数据时也会出现内存不足?使用“Quadro m1000m 4GB GPU”
【发布时间】:2018-07-18 14:29:06
【问题描述】:
Resource exhausted: OOM when allocating tensor with shape[256,128,3,3] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc

在这里,我尝试使用 vgg 来学习使用 Fast.ai 课程的深度学习概念。当我尝试读取 4 张图像的小数据时,它也会显示上述空间中给出的错误。这是我正在使用的 vgg16 文件的链接: https://github.com/fastai/courses/blob/master/deeplearning1/nbs/vgg16.py

我在下面代码中的路径是示例数据的路径,其中仅包含 4-5 张图像。

path = "data/dogscats/sample/"

import vgg16
from vgg16 import Vgg16

batch_size = 4
vgg = Vgg16()
# Grab a few images at a time for training and validation.
# NB: They must be in subdirectories named based on their category
#batches = vgg.get_batches(path+'train', batch_size=batch_size)
val_batches = vgg.get_batches(path+'valid', batch_size=batch_size*2)
vgg.finetune(batches)
vgg.fit(batches, val_batches, nb_epoch=1)

【问题讨论】:

  • 您应该补充说您使用的是“Quadro m1000m 4GB GPU”
  • 对不起@MartinThoma 那么现在如何解决这个问题。
  • 尝试在 CPU 上执行。发生什么了?您收到哪个错误消息? (请将此添加到问题中!)

标签: python-3.x tensorflow deep-learning gpu theano


【解决方案1】:

我解决了这个问题。实际上 Tensowflow 版本需要大量内存,所以我将 Keras 后端更改为 Theano,这解决了这个问题,我猜这里与 VGG 无关。 切换可以在keras.json文件中的.keras文件夹中进行,后端改成theano即可。

【讨论】:

    猜你喜欢
    • 2017-04-25
    • 2015-01-18
    • 2020-11-08
    • 2019-06-19
    • 1970-01-01
    • 2018-07-10
    • 2020-12-22
    • 2019-04-15
    • 2023-03-09
    相关资源
    最近更新 更多