Install Tensorflow 2.0 in conda enviroment

Question:

I would like to know if anyone knows how can I install tensorflow==2.0.0-alpha0 in a conda enviroment using python 3.7. Is it possible to use python 3.7 or do I have to downgrade to 3.6. Either way what is the command I need to use because the following don’t find any package

conda install tensorflow==2.0.0-alpha0
conda install tensorflow 
conda install tensorflow=2.0.0-alpha0

I am using fedora 29 and conda 4.6.8
Thanks!

Asked By: polmonroig

||

Answers:

You might want to take a look at this link: https://pypi.org/project/tf-nightly-2.0-preview/#files to see which python version and OS supports your package

enter image description here

Answered By: jgoday

It could be the case that the package version you want is not available in conda-forge. What you could do is install packages with pip in your conda environment.

pip install tensorflow==2.0.0-alpha0 

Also the requirements don’t state python 3.7, you can try your luck or downgrade to python 3.6.

Answered By: MDah

The problem is in conda install tensorflow.

conda does not have tensorflow. You will require to install tensorflow using pip. You do not need to downgrade your Python. It will work with Python 3.7.

Use this

$ pip install --upgrade tensorflow==2.0.0-beta0

Since the beta0 version is released, I mentioned that. You can choose other tf version.

I recommend going through this post on TowardsDataScience: Step-by-Step Guide to Install Tensorflow 2.0.

This post covers installation steps with conda.

Answered By: inferno

TENSORFLOW 2.0 release version is out!

Since 01/10/2019 I’m not talking beta but the release version.

Using Anaconda

Since 01/11/2019 Anaconda is supporting the Tensorflow 2.0.0.

Option 1: For what the easiest way is just:

conda install tensorflow or conda install tensorflow-gpu

For the gpu mode, anaconda will take care of all the CUDA everything you need to install for the tensorflow gpu mode to work so I strongly recommend using this method.

The only issue with this method is that anaconda might not have the last last version of TensorFlow. For example, at Feb 21 2021, conda has the version 2.3 whereas the PIP version is 2.4. You can check the current version of gpu or cpu.

Option 2 (virtual env): It is strongly recommended to use an environment on where to install tensorflow, for which you need the following command that will create an environment first and then install tensorflow within:

  • CPU: conda create -n <your_env_name> tensorflow
  • GPU: conda create -n <your_env_name> tensorflow-gpu

Change <your_env_name> by a meaningful name like tf-2

To use tensorflow run first conda activate <your_env_name>

Using pip

Using pip the tensorflow official instructions are quite complete.

Just install tensorflow using pip like:

# Current stable release for CPU-only
pip install tensorflow

I yet recommend before doing everything to install tensorflow in a new environment so the 3 steps would be (with anaconda):

conda create --n <our_env_name> pip
conda activate <your_env_name>
pip install tensorflow

Now for the GPU version it’s harder with pip, I recommend you this link that explains the extra things you need to install (CUDA and others).

Answered By: Agustin Barrachina

You can now install TF2 for Python 3.7 using conda. You can run the usual

$ conda install tensorflow=2.0 python=3.7

or

$ conda install tensorflow-gpu=2.0 python=3.7

for the GPU version.

My preferred approach however would be to manage the dependencies using an environment.yml file. You can find examples of how to do this for TF2 and dependencies in these template repos that I created on GitHub.

https://github.com/kaust-vislab/tensorflow-cpu-data-science-project

https://github.com/kaust-vislab/tensorflow-gpu-data-science-project

Answered By: davidrpugh

I tried to install tensorflow v2 with conda install tensorflow or conda install tensorflow-gpu only to get lots of incompatible dependencies.

Just run

pip install -upgrade tensorflow-gpu

or

pip install tensorflow-gpu=2.0.0 for a specific version

Answered By: QaraQoyunlu

Use ‘ pip install tensorflow-gpu ‘. This command does the job – downloads Tensorflow-gpu = 2.4.1

Answered By: Ujwala Kori Raj
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.