Can I run Keras model on gpu?



Yes you can run keras models on GPU. Few things you will have to check first.

1.your system has GPU (Nvidia. As AMD doesn’t work yet)

2.You have installed the GPU version of tensorflow

3.You have installed CUDA installation instructions

4.Verify that tensorflow is running with GPU check if GPU is working

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))


from tensorflow.python.client import device_lib


output will be something like this:

[ name: "/cpu:0"device_type: “CPU”, name: "/gpu:0"device_type: “GPU” ]

Once all this is done your model will run on GPU:

To Check if keras(>=2.1.1) is using GPU:

from keras import backend as K


All the best.


“You need to add the following block after importing keras. I am working on a machine which have 56 core cpu, and a gpu.”

import keras

config = tf.ConfigProto( device_count = {‘GPU’: 1 , ‘CPU’: 56} )

sess = tf.Session(config=config)