Abhishek Prajapat
Abhishek Prajapat

Reputation: 1888

Tensorflow(2.0), Keras not using VRAM from GPU but the GPU clock still spikes

I am running a convolutional neural network from a course on Deep Learning on Udemy but when I do so I can see that my GPU clock spikes but the GPU percentage usage is still 5% and even one epoch over 8000 images of mean size 300*400 takes a time of about 5 minutes.

I have Windows 10, RAM - 8GB, GPU - Nvidia Geforce Gtx 1060 6GB

The full code is here:

# Convolutional neural network
from keras.models import Sequential
from keras.layers import Conv2D,MaxPooling2D,Flatten,Dense

# Initializing CNN
cl = Sequential()

# Convolution
cl.add(Conv2D(32,3,3, input_shape=(64,64,3),activation='relu'))

# Polling
cl.add(MaxPooling2D(pool_size=(2,2)))

# Flattening
cl.add(Flatten())

# Full Connection
cl.add(Dense(128,activation='relu'))
cl.add(Dense(1,activation='sigmoid'))

# Compiling the CNN
cl.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])

# Fitting the CNN

from keras.preprocessing.image import ImageDataGenerator

train_datagen = ImageDataGenerator(rescale = 1./255,
                                   shear_range = 0.2,
                                   zoom_range = 0.2,
                                   horizontal_flip = True)

test_datagen = ImageDataGenerator(rescale = 1./255)

training_set = train_datagen.flow_from_directory('dataset/training_set',
                                             target_size = (64, 64),
                                             batch_size = 100,
                                             class_mode = 'binary')

test_set = test_datagen.flow_from_directory('dataset/test_set',
                                        target_size = (64, 64),
                                        batch_size = 100,
                                        class_mode = 'binary')

cl.fit_generator(training_set,
                     steps_per_epoch = 8000,
                     epochs = 25,
                     validation_data = test_set,
                     validation_steps = 2000)

Upvotes: 0

Views: 144

Answers (1)

QWERTYL
QWERTYL

Reputation: 1383

The same thing happened to me. If you download gpu-z you will see the GPU load is actually much higher than it says on task manager.

Upvotes: 0

Related Questions