50

I have tensorflow 1.2.1 installed, and I need to downgrade it to version 1.1 to run a specific tutorial. What is the safe way to do it? I am using windows 10, python 3.5. Tensorflow was installed with pip3, but "pip3 show tensorflow" returns blank.

Is it possible to have multiple version of tensorflow on the same OS?

askedAug 18, 2017 at 6:35
Yee's user avatar

9 Answers9

64

Pip allows to specify the version

pip install tensorflow==1.1

answeredAug 18, 2017 at 6:53
Jürg W. Spaak's user avatar
Sign up to request clarification or add additional context in comments.

4 Comments

Do I need to uninstall version 1.2 first? pip uninstall tensorflow doesn't work.
@Yee no, you don't have to first uninstall it, pip will do this directly. However right now I'm not able to reinstall tensorflow aswell, so not sure what the problem is...
If you have tensorflow 2, then running this will remove tensorflow 2 and install a lower version.
This only works for the given set of versions. In my case (a good lot later), this is only(from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1)
14

I discovered the joy of anaconda:https://www.continuum.io/downloads. It allows multiple virtual environments to host different versions of phyton and tensorflow. For example the following creates a virtual environment with pyton3.5 and tensorflow1.1

C:> conda create -n tensorflow1.1 python=3.5C:> activate tensorflow1.1(tensorflow1.1) C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl

voila, a virtual environment is created.

answeredAug 18, 2017 at 8:41
Yee's user avatar

Comments

12

Is it possible to have multiple version of tensorflow on the same OS?

Yes, you can use python virtual environments for this. From thedocs:

A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.

After you have install virtualenv (see thedocs), you can create a virtual environment for the tutorial and install the tensorflow version you need in it:

PATH_TO_PYTHON=/usr/bin/python3.5virtualenv -p $PATH_TO_PYTHON my_tutorial_env source my_tutorial_env/bin/activate # this activates your new environmentpip install tensorflow==1.1

PATH_TO_PYTHON should point to where python is installed on your system. When you want to use the other version of tensorflow execute:

deactivate my_tutorial_env

Now you can work again with the tensorflow version that was already installed on your system.

answeredAug 18, 2017 at 7:29
GeertH's user avatar

Comments

7

If you are using python3 on windows then you might do this as well

pip3 install tensorflow==1.4

you may select any version from "(from versions: 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0)"

I did this when I wanted to downgrade from 1.7 to 1.4

answeredApr 2, 2018 at 17:35
Omkar's user avatar

2 Comments

I got this ERROR: Could not find a version that satisfies the requirement tensorflow==1.6.0rc1 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1) ERROR: No matching distribution found for tensorflow==1.6.0rc1
This only works for the given set of versions. In my case (a good lot later), this is only(from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1)
7

Pay attention:you cannot install arbitrary versions of tensorflow, they have to correspond to your python installation, which isn't conveyed by most of the answers here. This is also true for thecurrent wheels like here (fromthis answer above). For this example, thecp35-cp35m found inside the url hints that it is for Python 3.5.x

A huge list of different wheels/compatibilities can be foundhere on github.By using this, you can downgrade to almost every availale version in combination with the respective for python. For example:

pip install tensorflow==2.0.0

(note that previous to installing Python 3.7.8 alongside version 3.8.3 in my case, you would get this:

ERROR: Could not find a version that satisfies the requirement tensorflow==2.0.0 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1)ERROR: No matching distribution found for tensorflow==2.0.0

this also holds true for other non-compatible combinations.)

This should also be useful for legacy CPU without AVX support or GPUs with a compute capability that's too low.


If you only need the most recent releases (which it doesn't sound like in your question) a list of urls for the current wheel packages is available onthis tensorflow page. That's from thisSO-answer.

Note:This link to a list of different versions didn't work for me.

answeredJul 11, 2020 at 22:10
Cadoiz's user avatar

1 Comment

More Information that could be useful can be found in this answer:stackoverflow.com/a/63102518/4575793
1

You can try to use the options of--no-cache-dir together with-I to overwrite the cache of the previous version and install the new version. For example:

pip3 install --no-cache-dir -I tensorflow==1.1

Then use the following command to check the version of tensorflow:

python3 -c ‘import tensorflow as tf; print(tf.__version__)’

It should show the right version got installed.

answeredJan 24, 2019 at 2:24
Jack Chan's user avatar

3 Comments

For me, this did not work, but simply runningpip install tensorflow==[version] did work to downgrade.
What do you mean this did not work? --no-cache-dir -I option did not help to overwrite the cache of the previous version? Usually a simple pip install command with no options (as you and other solutions above mentioned) would work. But, just in some systems, as the cache of the previous session is there, it doesn't allow the older version to be installed. That's why I suggested use the above options to overwrite the cache.
This only works for the given set of versions. In my case (a good lot later), this is only(from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.3.0rc0, 2.3.0rc1)
1

If you have anaconda, you can just install desired version and conda will automatically downgrade the current package for you.

For example:

conda install tensorflow=1.1
answeredFeb 21, 2020 at 0:31
Michael Zhang's user avatar

1 Comment

Note: this needs anaconda.
1

Click to green checkbox on installed tensorflow and choose needed versionscreenshot Anaconda navigator

answeredAug 16, 2020 at 21:40
redflasher's user avatar

Comments

0

You can downgrade TensorFlow version to a lower version by running:

1.Check the version of TensorFlow that currently installed by:

pip3 show tensorflow

2.Then, Downgrade TensorFlow to a lower version by running:

pip3 install --upgrade tensorflow==<version>

Set the version to a lower number than the currently installed release. When choosing, make sure the version is compatible with the Python release.

If you are using a Notebook environment, run the following command and restart the kernel when the installation completes:

!pip install --upgrade tensorflow==<version>

Although the best practice is to use the latest version of Python andTensorFlow since older versions have vulnerability issues. So becautious when downgrading.

answeredDec 16, 2022 at 8:04
Ali Masaoodi's user avatar

Comments

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.