How To Install TensorFlow on Ubuntu

TensorFlow is a wildly popular open-source framework used for numerical computation that makes building machine learning algorithms easy and convenient. In fact, many major companies use TensorFlow, including NVIDIA, Google, Uber, Netflix, AMD, and Target. In this article, we will learn how to install TensorFlow on Ubuntu.

TensorFlow owes its popularity to several key factors:

  • TensorFlow has made Machine Learning easy: Thanks to TensorFlow’s pre-trained models, data, and high-level APIs, now anyone can easily build ML models.
  • It’s heavily used by researchers: A large number of researchers and students use TensorFlow in the course of their research and model building.
  • TensorFlow provides ready-made models for production purposes: TensorFlow supports pre-trained models which can be instantly deployed for production and experiments.
  • ML is regarded as a service thanks to TensorFlow: Machine Learning is now considered a service thanks to the advent of TensorFlow. ML specialists can use the featured TensorFlow models to meet any modeling requirements.
  • It’s used by many organizations and companies: TensorFlow is employed by a wide number of companies such as Airbnb, DeepMind, Google, Intel, Twitter, Uber, DropBox, to name a few. In fact, more than 400 companies currently use TensorFlow!

Let’s get a little better acquainted with TensorFlow before we deal with installation issues.

What is TensorFlow?

TensorFlow is an open-source library that the Google Brain team developed in 2012. It is written in Python, Cuda, and C++. 

The initial version of TensorFlow was released under the Apache License in November 2015. The latest major release—TensorFlow 2.0—came out in September 2019. Incremental releases have been released since, and more are still in the works. The latest TensorFlow incremental release was version 2.6.1, released in November of 2021.

Your AI/ML Career is Just Around The Corner!

AI Engineer Master's ProgramExplore Program
Your AI/ML Career is Just Around The Corner!

TensorFlow’s Applications and Uses

  • Image and facial recognition
  • Health care related applications such as cancer, tumor detection, etc
  • Recommendation systems
  • Virtual assistants
  • Self-driving automobiles
  • Natural Language Processing (NLP)

The TensorFlow library leverages machine learning and deep learning. TensorFlow was initially developed to run large sets of numerical computations by analyzing data in the form of arrays of large amounts of data illustrated by flowcharts, and more. 

In practice, this data analysis will reveal the outstanding dimensions of any initial premise. Let’s dig in.

What is a Tensor, Anyway?

A tensor is a mathematical object represented as an array of a higher dimension. These arrays of data—with different dimensions and ranks—are fed as input to the neural network to process and build a neural network model.

dimension

Prerequisites for Installing TensorFlow on Ubuntu

  1. An Ubuntu Linux system (16.04 version or later)
  2. Python 3.5 or the latest version
  3. Pip 19.0 or newer versions
  4. A user account with sudo privileges

Steps for Installing TensorFlow on Ubuntu

1. Install the Python Development Environment

You need to download Python, the PIP package, and a virtual environment. If these packages are already installed, you can skip this step. 

You can download and install what is needed by visiting the following links:

https://www.python.org/

https://pip.pypa.io/en/stable/installing/

https://docs.python.org/3/library/venv.html

To install these packages, run the following commands in the terminal:

sudo apt update

sudo apt install python3-dev python3-pip python3-venv

2. Create a Virtual Environment

Navigate to the directory where you want to store your Python 3.0 virtual environment. It can be in your home directory, or any other directory where your user can read and write permissions.

mkdir tensorflow_files

cd tensorflow_files

Now, you are inside the directory. Run the following command to create a virtual environment:

python3 -m venv virtualenv

The command above creates a directory named virtualenv. It contains a copy of the Python binary, the PIP package manager, the standard Python library, and other supporting files.

3. Activate the Virtual Environment

source virtualenv/bin/activate

Once the environment is activated, the virtual environment’s bin directory will be added to the beginning of the $PATH variable. Your shell’s prompt will alter, and it will show the name of the virtual environment you are currently using, i.e. virtualenv.

4. Update PIP

pip install --upgrade pip

5. Install TensorFlow

The virtual environment is activated, and it’s up and running. Now, it’s time to install the TensorFlow package. 

pip install -- upgrade TensorFlow

To check if TensorFlow has been installed successfully, run the following lines of code on Jupyter Notebook. Print the version of TensorFlow, and perform a mathematical operation.

import-tensor

The lines of code above can be run in command prompt or on any Python IDE. If someone is using Jupyter Notebook for all of their code, for instance, they can run the same commands here as well.

Your AI/ML Career is Just Around The Corner!

AI Engineer Master's ProgramExplore Program
Your AI/ML Career is Just Around The Corner!

Conclusion

TensorFlow helps users implement complex machine learning and deep learning models to solve business problems. In this article, we covered the TensorFlow installation on Ubuntu. Do you have any questions for us? Please leave it in the comment section below, and we’ll get back to you quickly!

Want to Learn Even More About TensorFlow?

As more and more companies adopt TensorFlow, they need highly qualified professionals who have the right skills. According to Indeed, Machine Learning engineers in the United States earn an annual average of USD 131,073. Furthermore, Glassdoor reports that the national annual average for Machine Learning engineers in India is ₹842,482.

If you’re interested in pursuing a more rewarding and challenging career, or just adding Flowcharts to your tool belt, check out Simplilearn’s AI ML Course, in partnership with Purdue University, today. And if you want to take your Machine Learning and Artificial Intelligence career in a different direction, sign up for Simplilearn’s Artificial Intelligence Course, held in collaboration with IBM.

Artificial Intelligence and Machine Learning are the way of the future. Let Simplilearn help you in exploring this brave new world, and set you up in a secure, exciting new vocation!

About the Author

Avijeet BiswalAvijeet Biswal

Avijeet is a Senior Research Analyst at Simplilearn. Passionate about Data Analytics, Machine Learning, and Deep Learning, Avijeet is also interested in politics, cricket, and football.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, OPM3 and the PMI ATP seal are the registered marks of the Project Management Institute, Inc.