Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Tensorflow 2.0 in conda enviroment

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!

like image 849
polmonroig Avatar asked Mar 28 '19 07:03

polmonroig


4 Answers

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).

like image 190
Agustin Barrachina Avatar answered Nov 05 '22 06:11

Agustin Barrachina


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.

like image 44
MDah Avatar answered Nov 05 '22 04:11

MDah


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

like image 17
davidrpugh Avatar answered Nov 05 '22 05:11

davidrpugh


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.

like image 7
inferno Avatar answered Nov 05 '22 06:11

inferno