How can I test if Keras is properly configured for a Tensorflow backend?

How can I test if Keras is properly configured for a Tensorflow (GPU) backend on a Ubuntu 16.04 x64 linux machine running python 3 and installed via anaconda (and pip through conda for tensorflow)?

I tried installing keras, but it looked like it then installed theano, so I don’t know how to tell what it is using.

Is there a tutorial which people here would recommend for setting this up?

You can try doing this first and see if you get similar output saying it uses TF and loads CUDA.

$ KERAS_BACKEND=tensorflow python -c "from keras import backend"                                                                            
Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.7.5 locally

Another thing you can try then is to check the output of nvidia-smi when your NN is training and you should see the process taking up some of the GPU memory. Not sure if this is the best way to check, but it seems to work :slight_smile:

2 Likes

Keras reports only “Using TensorFlow backend.” This confirms it isn’t using Theano at least. Does this mean that it is using the CPU?

I tried this on two different machines, both running Ubuntu 16.04 but one with a Maxell and the other a Pascal GPU, and neither reported anything about CUDA. Both have CUDA and Cudnn installed, so I’m confused.

Is there a way to check GPU / CPU versions of tensorflow?