How do I know I am running Keras model on gpu?

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

to install tensoflow-gpu on anaconda:

conda install -c anaconda tensorflow-gpu

3. You have installed CUDA installation instructions

to install conda on anaconda:

conda install -c anaconda cudatoolkit

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 KK.tensorflow_backend._get_available_gpus()

You need to add the following block after importing keras if you are working on a machine, for example, which have 56 core cpu, and a gpu.

import kerasconfig = tf.ConfigProto( device_count = {‘GPU’: 1 , ‘CPU’: 56} ) sess = tf.Session(config=config) keras.backend.set_session(sess)

Of course, this usage enforces my machines maximum limits. You can decrease cpu and gpu consumption values.

more discussion see:

Here is video showing how to get GPU Support for TensorFlow and Keras.

Please check my recently published articles:

?Python for finance series

  1. Identifying Outliers
  2. Identifying Outliers ? Part Two
  3. Identifying Outliers ? Part Three
  4. Stylized Facts
  5. Feature Engineering & Feature Selection
  6. Data Transformation

No Responses

Write a response