How to check if keras tensorflow backend is GPU or CPU version?

matchifang picture matchifang · Jul 13, 2017 · Viewed 125.1k times · Source

I understand that when installing tensorflow, you either install the GPU or CPU version. How can I check which one is installed (I use linux).

If the GPU version is installed, would it be automatically running on CPU if GPU is unavailable or would it throw an error? And if GPU is available, is there a specific field or value you need to set to make sure it's running on GPU?

Answer

Bumseok picture Bumseok · Nov 22, 2017

Also you can check using Keras backend function:

from keras import backend as K
K.tensorflow_backend._get_available_gpus()

I test this on Keras (2.1.1)