Keras with TensorFlow backend not using GPU

后端 未结 3 1692
余生分开走
余生分开走 2020-11-29 08:21

I built the gpu version of the docker image https://github.com/floydhub/dl-docker with keras version 2.0.0 and tensorflow version 0.12.1. I then ran the mnist tutorial https

相关标签:
3条回答
  • 2020-11-29 09:02

    In the future, you can try using virtual environments to separate tensorflow CPU and GPU, for example:

    conda create --name tensorflow python=3.5
    activate tensorflow
    pip install tensorflow
    

    AND

    conda create --name tensorflow-gpu python=3.5
    activate tensorflow-gpu
    pip install tensorflow-gpu
    
    0 讨论(0)
  • 2020-11-29 09:11

    It is never a good idea to have both tensorflow and tensorflow-gpu packages installed side by side (the one single time it happened to me accidentally, Keras was using the CPU version).

    I guess now I need to figure out how to have keras use the gpu version of tensorflow.

    You should simply remove both packages from your system, and then re-install tensorflow-gpu [UPDATED after comment]:

    pip uninstall tensorflow tensorflow-gpu
    pip install tensorflow-gpu
    

    Moreover, it is puzzling why you seem to use the floydhub/dl-docker:cpu container, while according to the instructions you should be using the floydhub/dl-docker:gpu one...

    0 讨论(0)
  • 2020-11-29 09:13

    I had similar kind of issue - keras didn't use my GPU. I had tensorflow-gpu installed according to instruction into conda, but after installation of keras it simply not listed GPU as available device. I've realized that installation of keras adds tensorflow package! So I had both tensorflow and tensorflow-gpu packages. I've found that there is keras-gpu package available. After complete uninstallation of keras, tensorflow, tensorflow-gpu and installation of tensorflow-gpu, keras-gpu the problem was solved.

    0 讨论(0)
提交回复
热议问题