How do I check if keras is using gpu version of tensorflow?

You are using the GPU version. You can list the available tensorflow devices with (also check this question):

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices()) # list of DeviceAttributes

EDIT:

With tensorflow >= 1.4 you can run the following function:

import tensorflow as tf
tf.test.is_gpu_available() # True/False

# Or only check for gpu's with cuda support
tf.test.is_gpu_available(cuda_only=True) 

EDIT 2:

The above function is deprecated in tensorflow > 2.1. Instead you should use the following function:

import tensorflow as tf
tf.config.list_physical_devices('GPU')

NOTE:

In your case both the cpu and gpu are available, if you use the cpu version of tensorflow the gpu will not be listed. In your case, without setting your tensorflow device (with tf.device("..")), tensorflow will automatically pick your gpu!

In addition, your sudo pip3 list clearly shows you are using tensorflow-gpu. If you would have the tensoflow cpu version the name would be something like tensorflow(1.1.0).

Check this issue for information about the warnings.

Leave a Comment