title: ResourceExhaustedError (see above for traceback): OOM when allocating tensor of shape [3,3,256,512] and type float
body: <pre><code>import keras
  from keras.models import Sequential
  from keras.layers import Dense,Flatten,Dropout
  from keras.layers.convolutional import Conv2D,MaxPooling2D
  #from sklearn.model_selection import train_test_split
  import keras.optimizers
  import gc
  label=pd.read_csv('trainLabels.csv')
  label=label.sort_values(by=['image'])
  model = Sequential()
  model.add(Conv2D(64,(3,3),strides=(1,1),input_shape=(512,512,3),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(64,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(MaxPooling2D(pool_size=(2,2)))
  model.add(Conv2D(128,(3,2),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(128,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(MaxPooling2D(pool_size=(2,2)))
  model.add(Conv2D(256,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(256,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(256,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(MaxPooling2D(pool_size=(2,2)))
  model.add(Conv2D(512,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(512,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(512,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(MaxPooling2D(pool_size=(2,2)))
  model.add(Conv2D(512,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(512,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(Conv2D(512,(3,3),strides=(1,1),padding='same',activation='relu',kernel_initializer='uniform'))
  model.add(MaxPooling2D(pool_size=(2,2)))
  model.add(Flatten())
  model.add(Dense(4096,activation='relu'))
  model.add(Dropout(0.5))
  model.add(Dense(4096,activation='relu'))
  model.add(Dropout(0.5))
  model.add(Dense(1,activation='relu'))
  opt = keras.optimizers.Adagrad(lr=0.01)
  model.compile(loss='mean_squared_error', optimizer=opt)
  #ID=train_test_split(list(range(1000)),test_size=0.2,stratify=label['level'].iloc[0:1000])
  df=np.array(df)
  model.fit(df, label['level'].iloc[0:1000],epochs=100, batch_size=1)
  gc.collect()
  </code></pre>
  
  <p>GPU:GTX980M-8GB
  CPU: 2.7GHZ 8cores<br>
  Memeory: 16GB</p>
  
  <pre><code>df.shape
      Out[78]: (1000, 512, 512, 3)
  </code></pre>
  
  <p>error message:</p>
  
  <pre><code>ResourceExhaustedError (see above for traceback): OOM when allocating tensor of shape [3,3,256,512] and type float
       [[Node: training_9/Adagrad/zeros_14 = Const[dtype=DT_FLOAT, value=Tensor&lt;type: float shape: [3,3,256,512] values: [[[0 0 0]]]...&gt;, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]
  </code></pre>
  
  <p>The images are 512 X 512, and throughing a kind of standard vgg19
  I am just asking is this problem caused by hardware drawbacks and can't be solved by any other methods? i.e. I can't processing 512 X 512 image via vgg19 using a 8GB GPU. I am kind of doubt that since there must be the same error using 11GB GPU while adding on the batch size. Or there should be something wrong or other solutions.</p>