Skip to content Skip to sidebar Skip to footer

Error While Importing Keras And Tensorflow

I used from keras.layers import dot and got this error in return: c:\users\prashasti\appdata\local\programs\python\python37-32\lib\site-packages\tensorflow\python\pywrap_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:

  1. Install anaconda win 64 with python 3.7 as one package
  2. After Anaconda install, need to set the path C:\Users\username\Anaconda3\Scripts
  3. update pip
  4. Conda update
  5. conda create -n tf20 python=3.7
  6. pip install numpy
  7. pip install "tensorflow>=1.15,<2.0"
  8. pip install "tensorflow-gpu>=1.15,<2.0" (If GPU support needed)
  9. pip install keras (installed with latest 2.4.2)
  10. pip install --upgrade tensorflow-hub
  11. 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

    1. Check environment settings of CUDA, normally all the settings of CUDA had been added to Windows environment

    2. Copy files in bin, lib and include of cuDNN to bin, lib and include of CUDA respectively. Normally the directory is C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA

    3. And then you can import tensorflow and run your code. Good luck!

  • Solution -> 2

    1. Just run below command if necessary then update it

    2. pip install tensorflow==1.5

Post a Comment for "Error While Importing Keras And Tensorflow"