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)发布于 2018-02-10 15:03:19
我解决了这个问题。实际上,Tensowflow版本需要大量内存,所以我将Keras后端改为Theano,这解决了问题,我猜这里与VGG无关。切换可以在keras.json文件中的.keras文件夹中完成,并将后端更改为theano。
https://stackoverflow.com/questions/48678380
复制相似问题