D
D
DamskiyUgodnik2018-06-12 01:26:33
Neural networks
DamskiyUgodnik, 2018-06-12 01:26:33

How to use multiple GPUs in keras + tensorflow when training a network?

Hello!
I ran into a problem, when training a network, keras + tensorflow uses only one GPU, although there are several of them in the system (at the time of launch, tensorflow sees all the GPUs). I am using code like this:

datagen = ImageDataGenerator(rescale=1. / 255)

train_generator = datagen.flow_from_directory(
    'train_data/train',
    target_size=(150, 150),
    batch_size=128,
    class_mode='binary')

val_generator = datagen.flow_from_directory(
    'train_data/validation',
    target_size=(150, 150),
    batch_size=128,
    class_mode='binary')

model = Sequential()

# Формирование слоёв

model.compile(loss='binary_crossentropy',
              optimizer='adam',
              metrics=['accuracy'])

model.fit_generator(
    train_generator,
    steps_per_epoch=500,
    epochs=25,
    validation_data=val_generator,
    validation_steps = 150,
)

The question is how to use the rest of the GPU?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ivodopyanov, 2018-06-13
@ivodopyanov

https://keras.io/utils/#multi_gpu_model
https://www.pyimagesearch.com/2017/10/30/how-to-mu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question