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))

OR

from tensorflow.python.client import device_lib

print(device_lib.list_local_devices())

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: https://stackoverflow.com/questions/45662253/can-i-run-keras-model-on-gpu

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
2

No Responses

Write a response