Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing keras makes tensorflow can't find GPU #5776

Closed
thisray opened this issue Mar 15, 2017 · 5 comments
Closed

Installing keras makes tensorflow can't find GPU #5776

thisray opened this issue Mar 15, 2017 · 5 comments

Comments

@thisray
Copy link

thisray commented Mar 15, 2017

I have used keras + tensorflow-gpu in my old computer, it's very ok. (I forget the tensorflow version)

I install keras with tensorflow-gpu (version 1.0.1) in my new computer, and before install keras, tensorflow can find my GPU. But after install keras, tensorflow only can find CPU.
(use $ pip3 install keras)

I use these code to check GPU:

from tensorflow.python.client import device_lib
device_lib.list_local_devices() 
$ nvidia-smi

And I tried to install keras from source ($ python setup.py install), it would have some error and install fail.

...
Installed /home/thisray/keras-test/lib/python3.5/site-packages/Keras-2.0.0-py3.5.egg
Processing dependencies for Keras==2.0.0
Searching for tensorflow
Reading https://pypi.python.org/simple/tensorflow/
No local packages or working download links found for tensorflow
error: Could not find suitable distribution for Requirement.parse('tensorflow')

Is this problem about version ?

thanks

@ghost
Copy link

ghost commented Mar 15, 2017

Yeah, currently when you install Keras using pip or pip3 it blows off existing TF and installs the default, non-GPU version. It'd be great if there was a flag to not touch existing TF.

The workaround is to uninstall TF after installing Keras, and then installing the GPU version using pip or pip3 depending on your preferred python version. Not very elegant, but you gotta do what you gotta do.

@ghost
Copy link

ghost commented Mar 15, 2017

Argument in favor of more sophisticated handling: some folks use TF they have compiled themselves for their native machine architecture to speed up things like on-CPU image processing. For them to be reset to default TF when they upgrade is a bit of a nuisance.

@thisray
Copy link
Author

thisray commented Mar 15, 2017

Thanks for your explanation.
After: install tensorflow -> install keras -> uninstall tensorflow -> install tensorflow
and it works! Thanks a lot!

@adamcavendish
Copy link
Contributor

See #5766 . Use --no-deps

@holianh
Copy link

holianh commented Jan 9, 2019

Thank you very much!
install tensorflow -> install keras -> uninstall tensorflow -> install tensorflow

It worked for me

conda create -n ta  anaconda python
source activate ta
conda install tensorflow-gpu==1.11 cudatoolkit==9.0 cudnn==7.1.2 h5py
pip install pillow h5py keras
pip uninstall tensorflow
pip install tensorflow-gpu

python
import keras.backend as K;[x.name for x in K.get_session().list_devices()]
exit()

git clone https://github.com/fchollet/keras.git
cd keras/examples
python mnist_cnn.py

here is results:

2019-01-09 15:38:30.636492: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0 1 2 3 
2019-01-09 15:38:30.636499: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N Y N N 
2019-01-09 15:38:30.636504: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 1:   Y N N N 
2019-01-09 15:38:30.636508: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 2:   N N N Y 
2019-01-09 15:38:30.636512: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 3:   N N Y N 
2019-01-09 15:38:30.637425: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10405 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0, compute capability: 6.1)
2019-01-09 15:38:30.638060: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 10405 MB memory) -> physical GPU (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:03:00.0, compute capability: 6.1)
2019-01-09 15:38:30.638372: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:2 with 10405 MB memory) -> physical GPU (device: 2, name: GeForce GTX 1080 Ti, pci bus id: 0000:82:00.0, compute capability: 6.1)
2019-01-09 15:38:30.638638: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:3 with 10405 MB memory) -> physical GPU (device: 3, name: GeForce GTX 1080 Ti, pci bus id: 0000:83:00.0, compute capability: 6.1)
['/job:localhost/replica:0/task:0/device:CPU:0', '/job:localhost/replica:0/task:0/device:XLA_GPU:0', '/job:localhost/replica:0/task:0/device:XLA_CPU:0', '/job:localhost/replica:0/task:0/device:GPU:0', '/job:localhost/replica:0/task:0/device:GPU:1', '/job:localhost/replica:0/task:0/device:GPU:2', '/job:localhost/replica:0/task:0/device:GPU:3']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants