How to install Keras with gpu support?

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).


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.


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.


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

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

Similarly for keras-gpu