How to install Keras with gpu support?

前端 未结 4 1660
长发绾君心
长发绾君心 2021-01-01 20:00

I installed Tensorflow for GPU using: pip install tensorflow-gpu But when I tried the same for Keras pip install keras-gpu, it pu

4条回答
  •  一向
    一向 (楼主)
    2021-01-01 20:55

    There is not any keras-gpu package [UPDATE: now there is, see other answer below]; 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.

提交回复
热议问题