How to Install TensorFlow on Ubuntu 18.04 | 20.04

How to Install TensorFlow on Ubuntu 18.04 20.04

In this article, we are going to shows that how to Install TensorFlow on Ubuntu 18.04 | 20.04.

TensorFlow is an  end-to-end open-source and free software library for machine learning that is built by Google. It can be installed system-wide, in a Python virtual environment, as a Docker container, or with Anaconda.

The most easiest way to install TensorFlow is via a Python virtual environment where you can create and managed multiple environments easily.

Ubuntu is a Linux Operating System based on Debian and mostly composed of non-profit(free) and open-source software. It is a complete Linux operating system that compatible with desktops, laptops, server and other devices. Ubuntu is Open Source so it is freely available for both community and professional support.

if you are a learner and looking for a Linux distribution for Learning then Ubuntu Linux Operating System is best for you as a beginning.


How to install TensorFlow on Ubuntu

Simply follow below steps to installing TensorFlow on your Ubuntu system:

Step 1 : Install Python

By default, Python 3 comes with Ubuntu repositories. Run the command below to verify installed Python version on your system:

python3 -V

The above command display a output similar as below:

Output
Python 3.8.2

Step 2 : Create Virtual Environment

Run the command below to install the python3-venv package for creating a virtual environment:

sudo apt update
sudo apt install python3-venv python3-dev

The above command enable Python virtual environment for your TensorFlow project.


Step 3 : Create TensorFlow Directory

 To create a directory for TensorFlow, run the command below:

mkdir ~/tensorflow

Now change the directory by using cd command:

cd ~/tensorflow

Next, create a Python virtual environment by running command below:

python3 -m venv venv

When you run the above command, it will create a Python virtual environment named venv. Run the commands below to activate Python environment:

source venv/bin/activate

Step 4 : Install TensorFlow

To install the latest release of TensorFlow, run the commands below:

pip install --upgrade pip
pip install --upgrade tensorflow

A light-weight smaller CPU-only TensorFlow package is also available. Run the command below to install it:

pip install tensorflow-cpu

Run the commands below to verify the installation of TensorFlow:

python -c 'import tensorflow as tf; print(tf.__version__)'

The above command will display the version of TensorFlow installed.


Step 5 : Deactivate Python Environment

When once you are done your work with Python environment, you can deactivate the Python environment by running command below:

deactivate

The above command will Deactivate the Python environment and you will return to your normal shell.


That’s all

If you face any error and issue in above steps , please use comment box below to report.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top