Error While Importing Keras And Tensorflow
Solution 1:
I have CUDA 10.0 and cuDNN 7.6.4 I also getting this below error
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow
What I did was first uninstall everything like no python, no anaconda, no virtual env.
Then perform below steps:
- Install anaconda win 64 with python 3.7 as one package
- After Anaconda install, need to set the path C:\Users\username\Anaconda3\Scripts
- update pip
- Conda update
- conda create -n tf20 python=3.7
- pip install numpy
- pip install "tensorflow>=1.15,<2.0"
- pip install "tensorflow-gpu>=1.15,<2.0" (If GPU support needed)
- pip install keras (installed with latest 2.4.2)
- pip install --upgrade tensorflow-hub
- pip install keras==2.2.4 (downgraded to 2.2.4)
Now keras running with tensorflow 1.15 Probably you can do pip install keras==2.2.4 in step 9 and remove step 11. Just try once above steps from step 2 onwards before uninstall everthing. If that works that you can save your time. Good Luck :)
Please do let me know if this worked for you.
-Thanks
Solution 2:
Hey More then one solution for same problem -->
Solution -> 1
Check environment settings of CUDA, normally all the settings of CUDA had been added to Windows environment
Copy files in
bin,libandincludeof cuDNN tobin,libandincludeof CUDA respectively. Normally the directory isC:\Program Files\NVIDIA GPU Computing Toolkit\CUDAAnd then you can import tensorflow and run your code. Good luck!
Solution -> 2
Just run below command if necessary then update it
pip install tensorflow==1.5
Post a Comment for "Error While Importing Keras And Tensorflow"