Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "Keras requires TensorFlow 2.2 or higher"

I just installed Visual Studio 2019 and Tensorflow, but I cannot import Keras because I get the following error message:

Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow

The problem is that I had no choice but to install Tensorflow 1.15, because I have the following setup:

  • Visual Studio 2019
  • Python 3.7
  • CPU i7 920 (no avs, only SSE)
  • OS Windows 7 64
  • Nvidia GPU
  • CUDA 10.1

I had to download and install a wheel for that Python version, my CPU, and that CUDA version named "tensorflow-1.15.0-cp37-cp37m-win_amd64".

Tensorflow seems to work (it detects my GPU and prints a "hello world" message) but the problem is that Visual Studio installs the newest version of Keras.

How can I specify an older, compatible version, and what is the newer version compatible?

like image 731
tutizeri Avatar asked Jun 19 '20 07:06

tutizeri


People also ask

Does Keras require TensorFlow?

Does Keras depend on TensorFlow? No, Keras is a high-level API to build and train neural network models. Keras does not depend on TensorFlow, and vice versa . Keras can use TensorFlow as its backend.

Which version of TensorFlow does Keras support?

To start using Keras, simply install TensorFlow 2. Keras/TensorFlow are compatible with: Python 3.7–3.10.

Can install Keras without TensorFlow?

The recommended approach as of now and in the foreseeable future is to use the keras inside Tensorflow , as even Francois Chollet, the creator of Keras mentions this. Practically, you have to install only TensorFlow, and make all your imports like from tensorflow. keras.


2 Answers

I had the same issue caused by last keras release,what i remember did():

1-Upgrade tensorflow:

  pip install --user --upgrade tensorflow-gpu 

(there might be some missing packages, just pip install them)

2-Upgrade Tensorboard

pip install --user --upgrade tensorboard 

(there might be some missing packages, just pip install them)

3-Downgrade Keras

pip install keras==2.3.1 

(latest version working for me)

4-Downgrade tensorflow-gpu

pip install --user --upgrade tensorflow-gpu==1.14.0 

(latest version working for me)

Let me know if worked!


Anaconda 2020.02

Python 3.7

CPU i3 8100

OS Windows 10 64

Nvidia GPU GTX1050TI

CUDA 10.1

like image 175
Gustavo Zantut Avatar answered Oct 04 '22 10:10

Gustavo Zantut


Following the advice given here, downgrading Keras did the trick for me without having to touch any other packages. Just do:

pip install keras==2.3.0 

I hope this only remains a temporary issue and will be fixed in future versions of TensorFlow and Keras.

Other possible solutions, are discussed here.

like image 27
Hagbard Avatar answered Oct 04 '22 12:10

Hagbard