Using Tensorflow 1.13 and Keras 2.2.4 with Anaconda

11,744

Does this not work for you?

conda create -n keras-gpu pip python=3.6    
conda activate keras-gpu
pip install tensorflow-gpu==1.13.1 
pip install keras==2.2.4
Share:
11,744
machinery
Author by

machinery

Updated on June 04, 2022

Comments

  • machinery
    machinery almost 2 years

    I'm using Python with Anaconda. I have installed Tensorflow and Keras by creating a virtual environment:

    conda create -n keras-gpu python=3.6 numpy scipy keras-gpu
    

    I have used Python 3.6 because 3.7 is officially not yet supported by Keras. This installs Tensorflow 2.0.0 which is a problem because I have to change all imports from from keras.models import Sequential to from tensorflow.keras.models import Sequential. Moreover, while this approach works, pyCharm shows me that Sequential and models are unresolved reference and that keras cannot be found. By the way, how can I fix this? I included python.exe in the virtual environment as the interpreter.

    That's why I would like to use Tensorflow 1.13.1 and Keras 2.2.4. How can I create a virtual environment using this versions? keras-gpu just installs the newest versions.

    Or else is there a possibility to continue using from keras.models import Sequential with Tensorflow 2?

    • Dr. Snoopy
      Dr. Snoopy over 4 years
      I use Keras in python 3.7 every day, it is not true that it does not support it.
    • machinery
      machinery over 4 years
      @MatiasValdenegro Alright, I will try Python 3.7. Do you have a solution for the problem that PyCharm does not recognize tensorflow.keras etc. (although it works when running the script)?
    • machinery
      machinery over 4 years
      @MatiasValdenegro Is it possible to use import keras.models instead of import tensorflow.keras.models in TensorFlow 2? Otherwise I would have to change a lot in my code.