Keras does not use GPU on Pycharm having python 3.

2019-08-01 06:30发布

问题:

This question already has an answer here:

  • Keras with TensorFlow backend not using GPU 3 answers
from tensorflow.python.client
import device_lib
def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
xx= get_available_gpus()
print('The GPU device is: ', xx)
print('Tensorflow: ', tf.__version__)`

This gives me the following output.

Using TensorFlow backend.
2017-12-04 18:13:37.479189: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
The GPU device is:  []
Tensorflow:  1.4.0

I am using Pycharm community edition with python 3.5. Can anybody help in fixing how one can enforce to use GPU. Although while reading the documentation, I have found that Keras use GPU automatically. So what is the problem in my case that it does not use GPU? I also tried to uninstall Tensorflow, as suggested in some questions but still it does not use it. Need guidance.

回答1:

I solved it with the answer given by Keras with TensorFlow backend not using GPU

You need to uninstall both tensorflow and tensorflow-gpu. And than reinstall tensorflow-gpu. If both are installed than Keras will use only CPU version.