Keras Applications and Preprocessing Versions for TensorFlow

Viewed 5943

I'm getting the following message when I install the *.whl for TensorFlow. I'm installing from source just like this: https://www.tensorflow.org/install/install_sources

keras 2.2.2 has requirement keras-applications==1.0.4, but you'll have keras-applications 1.0.5 which is incompatible.
keras 2.2.2 has requirement keras-preprocessing==1.0.2, but you'll have keras-preprocessing 1.0.3 which is incompatible.
Installing collected packages: keras-applications, keras-preprocessing, tensorflow
  Found existing installation: Keras-Applications 1.0.4
    Uninstalling Keras-Applications-1.0.4:
      Successfully uninstalled Keras-Applications-1.0.4
  Found existing installation: Keras-Preprocessing 1.0.2
    Uninstalling Keras-Preprocessing-1.0.2:
      Successfully uninstalled Keras-Preprocessing-1.0.2
Successfully installed keras-applications-1.0.5 keras-preprocessing-1.0.3 tensorflow-1.10.0

Do you know why the installation removes the correct versions of Keras-Applications and Keras-Preprocessing, and reinstalls with the newer incompatible versions?

Thanks

1 Answers

It seems that you'll need Keras-2.1.6 instead of Keras-2.2.2. So, use

sudo -H pip uninstall Keras

to uninstall the current 2.2.2 version, then

sudo pip install Keras==2.1.6

Hopefully this can fix the issue you have.

Regarding the reason why this happens, I think it is because TensorFlow requires Keras-Applications>=1.0.5, and Keras-Preprocessing>=1.0.3. The package management algorithm always go with the latest available package, which bring to us Kera-2.2.2. Whereas latest Keras have an odd dependency requirement, which specifically requires Keras-Applications==1.0.4, and Keras-Preprocessing==1.0.2. My fix is to roll back Keras to a slight older version that have >= requirements, to make pip happy.

One step further, I think it is either a bug in Keras 2.2.2's dependency, or it is intensional because Keras 2.2.2 is somehow incompatible with latest Keras-Applications or Keras-Preprocessing.

Related