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.

We will cover the following:

  1. What is TensorFlow?
  2. What is a tensor?
  3. Prerequisites for installing TensorFlow on Ubuntu
  4. Steps for installing TensorFlow on Ubuntu

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

Deep Learning Course (with TensorFlow & Keras)

Master the Deep Learning Concepts and ModelsView Course
Deep Learning Course (with TensorFlow & Keras)

What is a Tensor?

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.

Want to gain expertise in Deep Learning? Then take up the Deep Learning Course (with Keras & TensorFlow) and start your career in Deep Learning.

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.

Want to Learn Even More About TensorFlow?

As more and more companies adopt TensorFlow, they are in need of highly qualified professionals who have the right skills. If you’re interested in adding Flowcharts

 to your tool belt, check out Simplilearn’s Deep Learning Course (with Keras and TensorFlow) Certification Training today!

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, and OPM3 are registered marks of the Project Management Institute, Inc.