title: GPU restart during CNN training using Tensoflow Keras Ubuntu 20.04
body: <p>i am training a simple CNN architecture on 33874 training and 9683 validation images belongs to 5 classes, at epoch 6 the computer restart and my training never completed. CNN architecture looks like:</p>
  <pre><code>model = models.Sequential()
  
  model.add(layers.Conv2D(32,(3, 3),activation= 'relu',input_shape=(224,224,3)))
  model.add(layers.Conv2D(32,(3, 3), activation= 'relu'))
  model.add(layers.MaxPooling2D((2, 2),padding=&quot;same&quot;))
  
  model.add(layers.Conv2D(64,(3, 3), activation='relu'))
  model.add(layers.Conv2D(64,(3, 3), activation='relu'))
  model.add(layers.MaxPooling2D((2, 2),padding=&quot;same&quot;))
  model.add(BatchNormalization())
  
  model.add(layers.Conv2D(128,(3, 3),activation='relu'))
  model.add(layers.Conv2D(128,(3, 3),activation='relu'))
  model.add(layers.MaxPooling2D((2,2),padding=&quot;same&quot;))
  model.add(layers.Flatten())
  model.add(layers.Dense(10,activation=&quot;relu&quot;))
  model.add(layers.Dense(5,activation=&quot;softmax&quot;))
  model.compile(loss=&quot;categorical_crossentropy&quot;,
            optimizer=tensorflow.optimizers.Adam(learning_rate = 0.0001), 
            metrics = ['accuracy'])
  
  model.summary()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/1dOki.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1dOki.png" alt="complete summary of model" /></a></p>
  <p>the images are pre process using ImageDataGenerator</p>
  <pre><code>img_height, img_width = 224,224
  # the no. imgaes to load at each iteration
  batch_size = 64
  # only rescaling
  train_datagen =  ImageDataGenerator(
      rescale=1./255,
      #featurewise_std_normalization=True,
     # samplewise_std_normalization=True,  shear_range=0.2,
      # zoom_range=0.2,
      brightness_range=[0.2,1.0], 
      featurewise_center=True,
      featurewise_std_normalization=True
        # horizontal_flip=True,
        #  vertical_flip=True
  )
  
  test_datagen =  ImageDataGenerator(
      rescale=1./255
  )
  # these are generators for train/test data that will read pictures #found in the defined subfolders of 'data/'
  print('Total number of images for &quot;training&quot;:')
  train_generator = train_datagen.flow_from_directory(
  train_data_dir,
  target_size = (img_height, img_width),
  batch_size = batch_size, 
  class_mode = &quot;categorical&quot;,shuffle = True #,  color_mode='grayscale'
  )
  
  #train_generator = train_generator.reshape(x_train.shape[0], x_train.shape[1], x_train.shape[2], 1)
  print('Total number of images for &quot;validation&quot;:')
  val_generator = test_datagen.flow_from_directory(
  val_data_dir,
  target_size = (img_height, img_width),
  batch_size = batch_size,
  class_mode = &quot;categorical&quot; ,#color_mode='grayscale',
  shuffle=False)
  print('Total number of images for &quot;testing&quot;:')
  test_generator = test_datagen.flow_from_directory(
  test_data_dir,
  target_size = (img_height, img_width),
  batch_size = batch_size,
  class_mode = &quot;categorical&quot;,
      #color_mode='grayscale',
  shuffle=False)
  </code></pre>
  <p>but my training is stopped anywhere and GPU restarted.</p>
  <p><a href="https://i.stack.imgur.com/xXOsE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xXOsE.png" alt="at middle of epoch 6 the GPU machine restarted and my training never complete" /></a>
  Help me as i used same no. images for Mobilnet_V2 Architecture on same machine and my GPU machine never restarted working with MobileNet_V2 Architecture.</p>