top of page

Keras & Tensorflow Compatible Issues

We need Keras to conduct the Behavioral Cloning.

In the process of installing and using Keras, I met some problems. The "carnd-term1" environment has already installed tensorflow 0.12.1 and keras 1.2.1, which have a well compatibility with each other. So we can directly use Keras in in the "carnd-term1" environment, but the installed Tensorflow is CPU based only. The "IntroToTensorflow" environment doesn't have any version of tensorflow, thus we can install tensorflow-gpu==1.4.0, and for safety considerations, I currently use Keras only in "carnd-term1" env without installing Keras into "IntroToTensorflow" env.

The following are the useful posts I found in the forum:

[How to install keras 1.2 in conda](https://discussions.udacity.com/t/how-to-install-keras-1-2-in-conda/342805):

"

You can uninstall the present package using pip and then install the keras 1.2 version. However, while uninstalling be sure and careful. Before uninstalling you can use:

$ pip freeze

to check what all packages you have and it’s version. So, there you will find keras and it’s proper version. Now you can:

$ pip uninstall package.name.you.have.found

Then you can install the keras you want:

$ pip install keras==1.2

"

[ImportError: No module named ‘keras.Models’](https://discussions.udacity.com/t/importerror-no-module-named-keras-models/240335/12)

--------------------------------------------------------------------------------------------------------------------------------------------------

The project involves python coding, thus a good editor, i.e. Spyder, is needed.

However, the "carnd-term1" environment doesn't work compatible with Spyder 3.6 (python 3.6) or Spyder 3.2.4 (python 3.5). More specifically, tensorflow 0.12.1 and keras 1.2.1 don't compatible with Spyder for reasons I didn't figure out. In fact, the python version is 3.5 in "carnd-term1" environment.

I switched to "IntroToTensorflow" because it uses python 3.6, installed tensorflow-gpu==1.4.0, and works well with spyder 3.6. The biggest issue is I still would like to use tensorflow-gpu instead of tensorflow-cpu after installing keras. The last time after installing keras, it forces me to use tensorflow-cpu. Moreover, the "IntroToTensorflow" doesn't contains "socketio" and "eventlet" which we need for "drive.py" coding. The following are the searched solutions:

For the "socketio" and "eventlet" installation:

  • The first step is to update "pip" otherwise the installation will show errors and won't succeed. Use "conda update pip": [old html5lib makes pip dysfunctional #588](https://github.com/tensorflow/tensorboard/issues/588)

  • Then install "socketio" and "eventlet" using "pip install socketio" and "pip install eventlet"

For tensorflow-gpu and keras:

Use "pip install --upgrade --no-deps keras" to installs keras without installing its dependency tensorflow-cpu: [Why explicitly depend on tensorflow on Keras 2.0? #5766](Why explicitly depend on tensorflow on Keras 2.0? #5766). This method works well, the tensorflow still use GPU after installing keras.

Complementary solutions: install keras -> uninstall tensorflow-gpu -> install tensorflow-gpu: [Installing keras makes tensorflow can't find GPU #5776](https://github.com/fchollet/keras/issues/5776).

Tensorflow, Keras and Anaconda version compatibility issue is still a open problem with a lot of headache. Be cautious before changing anything.

Recent Posts
Archive
bottom of page