1

I am trying to get my keras back-end to work, but it keeps telling that there is no GPU, but my tensorflow say otherwise.

tensorflow

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

Ouput

[name: "/device:CPU:0"
device_type: "CPU"
memory_limit: 268435456
locality {
}
incarnation: 7600201089948511065
, name: "/device:XLA_CPU:0"
device_type: "XLA_CPU"
memory_limit: 17179869184
locality {
}
incarnation: 9640434864482537344
physical_device_desc: "device: XLA_CPU device"
, name: "/device:XLA_GPU:0"
device_type: "XLA_GPU"
memory_limit: 17179869184
locality {
}
incarnation: 15836333527683385212
physical_device_desc: "device: XLA_GPU device"
]

keras

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

Output

[]

Tensorflow-gpu works, but keras can't see for some reason

Cuda is installed

tensorflow-gpu = 1.14.0
keras = 2.0.8
python = 3.6
4
  • 1
    Are you using any conda/virtualenv environment? Can you check if there are any global installations? Commented Sep 10, 2019 at 7:55
  • yes, but I currently install all package globally Commented Sep 10, 2019 at 8:15
  • I'm having the same problem. Have you tried uninstalling keras and installing keras-gpu? Are you using tf.keras to build and train models? Commented Oct 9, 2019 at 18:32
  • O I posted what i did Commented Oct 10, 2019 at 8:45

2 Answers 2

2

Few things that you need to confirm before this,

Which GPU are you using? Only NVIDIA works. Do you have tensorflow-gpu installed (keras uses this as its backend)? Do you have CUDA installed?

Since tensorflow is detecting GPU, then its either an issue with on of the above points, or you may try upgrading the various packages.

Lastly, if nothing else works I would recommend using the high level API in tensorflow2 which is actually the same as keras.

Hope this helps.

Sign up to request clarification or add additional context in comments.

2 Comments

I am using nvidia, tensorflow-gpu is installed
what about CUDA?
0

Add ppa to ubuntu repos, they have the newest driver. Risky, but worth it!

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

Try to install newest cuda driver

sudo ubuntu-drivers autoinstall

If this fails (like it did in my case), do sudo apt install for all dependencies it complains about.

In my case:

sudo apt install libnvidia-gl-435 nvidia-dkms-435 nvidia-kernel-source-435 

Tried again

sudo ubuntu-drivers autoinstall

reboot computer

Create a new conda env

conda create -n tf python=3.7

source activate tf


conda install -c anaconda keras-gpu tensorflow-gpu jupyter pytables pandas seaborn scikit-learn gensim -y

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.