21

I installed Tensorflow for GPU using: pip install tensorflow-gpu But when I tried the same for Keras pip install keras-gpu, it pulled me an error: could not find the version that satisfies the requirements.

nbro
  • 15,395
  • 32
  • 113
  • 196
Sai Krishnadas
  • 2,863
  • 9
  • 36
  • 69
  • 1
    Please state the version of Python used. Also note, keras-gpu is a conda install, not pip install. – Prabindh May 11 '19 at 08:59

4 Answers4

31

Adding to the answer below which is the correct answer in terms of recommending to use Anaconda package manager, but out of date in that there is now a keras-gpu package on Anaconda Cloud.

So once you have Anaconda installed, you simply need to create a new environment where you want to install keras-gpu and execute the command:

conda install -c anaconda keras-gpu

This will install Keras along with both tensorflow and tensorflow-gpu libraries as the backend. (There is also no need to install separately the CUDA runtime and cudnn libraries as they are also included in the package - tested on Windows 10 and working).

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Gus Long
  • 451
  • 5
  • 9
22

There is not any keras-gpu package [UPDATE: now there is, see other answer above]; Keras is a wrapper around some backends, including Tensorflow, and these backends may come in different versions, such as tensorflow and tensorflow-gpu. But this does not hold for Keras itself, which should be installed simply with

pip install keras

independently of whatever backend is used (see the PyPi docs).

Additionally, and since you have tagged the question as anaconda, too, be informed that it is generally not advisable to mix your package managers (i.e pip with conda), and you may be better off installing Keras from the Anaconda cloud with

conda install -c conda-forge keras 

Finally, you may be also interested to know that recent versions of Tensorflow include Keras as a subpackage, so you can use it without any additional installation; see https://www.tensorflow.org/guide/keras

For installing tensorflow-gpu from Anaconda cloud, you should use

conda install -c anaconda tensorflow-gpu 

before installing Keras. Be sure you do it in a different virtual environment, or after having uninstalled other versions (i.e. pip-installed ones), as there have been reported problems otherwise.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • so instead pip install tensorflow-gpu .. What can i use to install in a anaconda – Sai Krishnadas Feb 14 '19 at 11:38
  • @SaiKrishnadas see updated answer (it was a simple Google search, in any case...); and if the answer has been helpful, kindly accept it - thanks – desertnaut Feb 14 '19 at 11:55
  • Still.. **System information** * **Windows 7** * **pip install tensorflow-gpu** * Python version: **3.6.6** * Installed using virtualenv? pip? conda?: **pip** * CUDA/cuDNN version: **CUDA 8.0 cuDNN 7.1** * GPU model and memory: **Model : Quadro 4000 , Memory : 18GB** Installed using pip install tensorflow-gpu (No error, perfectly installed) While importing tensorflow , i got a error : **Failed to load native tensorflow .ImportError: DLL load failed: The specified module could not be found** – Sai Krishnadas Feb 14 '19 at 12:37
  • Your initial question was about `keras-gpu`, which has been addressed in the answer. If you have a **different** issue with a different package, you are very welcome to open a new question, after accepting this one. – desertnaut Feb 14 '19 at 12:56
4

Adding to the above two answers, ensure your TensorFlow/Keras environment is using Python 3.6. Keras/TensorFlow doesn't work very well with Python 3.7, as of May 10, 2019.

I tried to use Keras/TensorFlow with Python 3.7 and I ended up having to reinstall Anaconda, since it sort of broke my Anaconda Prompt.

Sean McCarthy
  • 4,838
  • 8
  • 39
  • 61
1

To install tensorflow-gpu with particular cuda version 9.0, use:

conda install tensorflow-gpu cudatoolkit==9.0 -c anaconda

Similarly for keras-gpu

desertnaut
  • 57,590
  • 26
  • 140
  • 166
SKG
  • 145
  • 1
  • 8