Jonas Sourlier
Jonas Sourlier

Reputation: 14475

Keras does not use GPU - how to troubleshoot?

I'm trying to train a Keras model on the GPU, with Tensorflow as backend.

I have set everything up according to https://www.tensorflow.org/install/install_windows. This is my setup:

However, Tensorflow does not see any usable GPU:

from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 5275203639471190827
]

Keras neither:

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

[]

How can I debug this? How can I find out where the problem is?

Upvotes: 12

Views: 10105

Answers (1)

kRazzy R
kRazzy R

Reputation: 1589

Check
nvcc -V
and

nvidia-smi

and see if it shows our gpu or not.

Assuming your cuda cudnn and everything checks out, you may just need to
1. Uninstall keras
2. Uninstall tensorflow
3. uninstall tensorflow-gpu
4. Install only tensorflow-gpu pip install tensorflow-gpu==1.5.0
5. Install Keras now.

I followed these steps, and keras now uses gpu.

Hope it helps to some extent.

Upvotes: 17

Related Questions