Source From Here
QuestionI have Keras installed with the Tensorflow backend and CUDA. I'd like to sometimes on demand force Keras to use CPU. Can this be done without say installing a separate CPU-only Tensorflow in a virtual environment? If so how? If the backend were Theano, the flags could be set, but I have not heard of Tensorflow flags accessible via Keras.
HowTo
If you want to force Keras to use CPU:
Way1
- import os
- os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152
- os.environ["CUDA_VISIBLE_DEVICES"] = ""
Way 2
Run your script as
See also
https://github.com/keras-team/keras/issues/152
https://github.com/fchollet/keras/issues/4613
沒有留言:
張貼留言