TensorFlow

Installation

Install TensorFlow 2


Install TensorFlow with conda

Install TensorFlow with pip
Anaconda TensorFlow


1. Install the Python development environment on your system

Check if your Python environment is already configured:

Requires Python 3.6–3.8, pip and venv >= 19.0



Show all envs:

CLI
1
conda info --envs

Remove env

CLI
1
conda env remove --name tf 

Add tf kernel to Jupyter

How to add conda environment to jupyter lab
How to add your Conda environment to your jupyter notebook in just 4 steps


Step 1: Create a Conda environment.
CLI
1
(base) ➜  ~ conda create --name tf


Step 2: Activate the environment using the command as shown in the console. After you activate it, you can install any package you need in this environment.

For example, I am going to install Tensorflow in this environment. The command to do so,

CLI
1
2
(base) ➜  ~ conda activate tf
(tf) ➜ ~ conda install -c conda-forge tensorflow


Step 3: Now you have successfully installed Tensorflow. Congratulations!!

Now comes the step to set this conda environment on your jupyter notebook, to do so please install ipykernel.

CLI
1
(tf) ➜  ~ conda install -c anaconda ipykernel

After installing this,
just type,

CLI
1
(tf) ➜  ~ python -m ipykernel install --user --name=tf


Step 4: Just check your Jupyter Notebook, to see the shining tf.


OPTIONAL: Install other Data Science Packages from previous env

NOT work for the migration from higher version of Python to lower version of Python

Managing environments

Assume your previous env is base

CLI
1
(tf) ➜  ~ conda activate base

EXPORT current env

``sh CLI
(base) ➜ conda list –export > /tmp/base.yml

1
2
3
4
5

Switch to env `tf`

```sh CLI
(base) ➜ ~ conda activate tf
CLI
1
(tf) ➜  ~ conda env update --file /tmp/base.yml   

Since base is Python 3.8.8, and tf is Python 3.7.7. There must be some errors. But the rest packages should work well.


Step 5: Install the missing packages in tf

Install needed packages manually

For example, I need to install package pandas and plotly.

For plotly installation, visit https://zacks.one/python-plotly/

CLI
1
2
(tf) ➜  ~ conda install pandas -y
(tf) ➜ ~ conda install tensorflow-probability -y

Run a TensorFlow container

Run a TensorFlow container