I know the default backend for Keras has switched from Theano to TensorFlow, but with the dev version of Theano I can train on the GPU with OpenCL (I have an AMD card).
However, when I import Keras, it only uses the TensorFlow backend even after I changed the values in the Keras configuration file:
~ $ cat $HOME/.keras/keras.json
{"epsilon": 1e-07, "floatx": "float32", "backend": "theano"}
~ $ python -c 'import keras'
Using TensorFlow backend.
~ $ KERAS_BACKEND=theano python -c 'import keras'
Using Theano backend.
Mapped name None to device opencl0:2: AMD Radeon R9 M370X Compute Engine
In addition, I know that Keras is reading the configuration file after import because if I fill some non-valid value for "backend"
I get an error:
~ $ cat $HOME/.keras/keras.json
{"epsilon": 1e-07, "floatx": "float32", "backend": "foobar"}
~ $ python -c 'import keras'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/antalek/anaconda/envs/ENVPy3/lib/python3.5/site-packages/keras/__init__.py", line 3, in <module>
from . import activations
File "/Users/antalek/anaconda/envs/ENVPy3/lib/python3.5/site-packages/keras/activations.py", line 3, in <module>
from . import backend as K
File "/Users/antalek/anaconda/envs/ENVPy3/lib/python3.5/site-packages/keras/backend/__init__.py", line 34, in <module>
assert _backend in {'theano', 'tensorflow'}
AssertionError
System details:
- Mac OSX 10.11.6
- Anaconda Python v 3.5
- Keras v 2.0.2
I would like to have Keras use Theano as the default backend. Anyone know how to set it as such?
EDIT:
To answer @Marcin Możejko 's question:
~ $ which python
/Users/<my name>/anaconda/envs/ENVPy3/bin/python
Which is the conda virtual environment that Keras is installed in as well.
python
in your console matching aconda
distribiution? – Mcleroy