user288609
user288609

Reputation: 13055

Install TensorFlow with specific version on Anaconda

TensorFlow has multiple versions, if I want to install a specific version in Anaconda, which command should I use?

Upvotes: 24

Views: 77487

Answers (6)

Bhanu Mahto
Bhanu Mahto

Reputation: 11

I have a older project which has dependency to run on:

Python: 3.7 
Tensorflow: 1.13.1

To create i used ananconda:

conda create -n tf python=3.7 tensorflow=1.13.1 
// here more modules with specific version can be added 

conda activate tf //Activate environment

(base) D:\ff\testM>  --> (tf) D:\ff\testM> 
// environment changes from base to tf

Upvotes: 0

Bhanu Mahto
Bhanu Mahto

Reputation: 11

I have a older project which has dependency to run on:

Python: 3.7 
Tensorflow: 1.13.1

For this I create a virutal environment using anancoda like:

conda create -n tf python=3.7 tensorflow=1.13.1 
// here more modules with specific version can be added 

After that we to activate env:

conda activate tf

after this ouput was:

(tf) D:\ff\testM>

Environment changed from (base) --> (tf)

(base) D:\ff\testM>

Upvotes: 0

Snehal Rajput
Snehal Rajput

Reputation: 436

To install specific version of python, tensorflow while creating conda environment: conda create -n python=3.6 tensorflow=1.12.0

Upvotes: 0

adamconkey
adamconkey

Reputation: 4745

I find the existing answers unsatisfying, as the OP asked specifically about Anaconda but the answers are just pip installs.

You can list the available versions for install doing

conda search tensorflow-gpu

which should give you some output that looks like

Loading channels: done
# Name                       Version           Build  Channel             
tensorflow-gpu                 1.4.1               0  pkgs/main           
tensorflow-gpu                 1.5.0               0  pkgs/main           
tensorflow-gpu                 1.6.0               0  pkgs/main           
tensorflow-gpu                 1.7.0               0  pkgs/main           
tensorflow-gpu                 1.8.0      h7b35bdc_0  pkgs/main           
tensorflow-gpu                 1.9.0      hf154084_0  pkgs/main           
tensorflow-gpu                1.10.0      hf154084_0  pkgs/main           
tensorflow-gpu                1.11.0      h0d30ee6_0  pkgs/main           
tensorflow-gpu                1.12.0      h0d30ee6_0  pkgs/main           
tensorflow-gpu                1.13.1      h0d30ee6_0  pkgs/main           
tensorflow-gpu                1.14.0      h0d30ee6_0  pkgs/main           
tensorflow-gpu                1.15.0      h0d30ee6_0  pkgs/main           
tensorflow-gpu                 2.0.0      h0d30ee6_0  pkgs/main           
tensorflow-gpu                 2.1.0      h0d30ee6_0  pkgs/main           
tensorflow-gpu                 2.2.0      h0d30ee6_0  pkgs/main

If you need to specify a particular channel, the -c/--channel option is your friend, for example:

conda search -c conda-forge tensorflow-gpu

Then you can select your version by passing it to the install command, for example:

conda install tensorflow-gpu==2.0.0

If you needed the channel option in your search, you should add the same option to the conda install command. Note this will work the same for tensorflow (i.e. not the GPU version), just change the package name accordingly.

YAML Configuration

If you use YAML environment configuration files, you can do the same thing:

# environment.yaml
name: my_conda_env
channels:
  - conda-forge
dependencies:
  - tensorflow-gpu=2.0.0

Create your environment with command:

conda env create -f environment.yaml

or if you change the version of an already created environment:

conda env update -f environment.yaml

Upvotes: 32

Cardin
Cardin

Reputation: 5507

This is probably the simplest way to do it:

pip install --ignore-installed --upgrade tensorflow==1.4

If you want to see all available versions, you can check out https://pypi.python.org/pypi/tensorflow/json

I would highly recommend you use virtualenv or conda to isolate your tensorflow installation, especially if you want to play-test different versions and the CPU/GPU versions.

Upvotes: 15

ksai
ksai

Reputation: 977

I am assuming that you are using Windows, python3.5, and CPU version of tensorflow.

let's first create conda environment.

C:> conda create -n tensorflow python=3.5 
C:> activate tensorflow
 (tensorflow)C:>  # Your prompt should change 

After creating the conda environment successfully, issue the correct command to install the specific version. I will guide you through installing three different versions.

To install version r1.0

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.1-cp35-cp35m-win_amd64.whl 

To install version r1.3

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0rc1-cp35-cp35m-win_amd64.whl 

To install master version

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.0-cp35-cp35m-win_amd64.whl 

let me know if this is what you are looking for

Upvotes: 3

Related Questions