How to install TensorFlow on Ubuntu 20.04?

Ubuntu is such a powerful and versatile operating system that it is used by all kinds of people with such varied requirements. Well, there are also users working with machine learning who need to install tools like Tensorflow in Ubuntu 20.04 and that is why we have prepared this post so that you can do it without any problem.

What is Tensorflow?

Application development is evolving more and more every day to solve complex problems in a very short time. These needs are getting closer every day to mimic and automate human responses on a computer. To answer this, TensorFlow was born.

Now, what is TensorFlow? Well, we have the answer on the project’s website:

According to the TensorFlow website:

TensorFlow is an end-to-end open-source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries, and community resources that lets researchers push the state-of-the-art in ML, and developers easily build and deploy ML powered applications.

What can we do with TensorFlow? Well, the answer is incredible because with this library we can do things that until not long ago were reserved for large companies.

Some of the things we can do using TensorFlow are:

  • Create applications with Artificial Intelligence and train them with Machine Learning.
  • Also, create neural networks, indispensable for a proper Machine Learning system.

In general, any system, application, or project that requires Machine Learning to offer certain options to users, can make use of TensorFlow.

On the other hand, it is compatible with many programming languages such as Java or Python, which are very popular.

In this post, we will focus on the installation with Python.

Install Tensorflow on Ubuntu 20.04

The installation of TensorFlow can be done using Python’s own tools. So you have to install them.

So, open a terminal and make sure the system is up to date.

sudo apt update
sudo apt upgrade

Now we have to install the Python development tools as well as the python3-venv package that will allow us to create virtual environments in this language.

sudo apt install python3-venv python3-dev

So, the next step is to create a folder where the virtual environment will be and access it:

mkdir tensor
cd tensor/

Now you can start the virtual environment. In this case, I have named it tensorf.

python3 -m venv tensorf

And activate it with the following command:

source tensorf/bin/activate

You will notice a change in the terminal that will look similar to this:

(tensorf) user@imaginelinux:~/tensor$

And now update PIP the Python package manager, before using it:

pip install --upgrade pip

After this, install TensorFlow using PIP

pip install --upgrade tensorflow

At the end of the output screen, you will see a message similar to this:

Successfully installed TensorFlow-2.4.1

Now you can check TensorFlow’s performance by displaying the current version.

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

Finally, you can deactive the environment:

deactivate

So, TensorFlow is ready to be used.

Conclusion

Ubuntu is ready for almost anything and the development of applications that use machine leaning on it is possible thanks to TensorFlow. This library is very powerful and popular and with it you can make many useful applications.

As we have shown you, installing it is relatively easy in Ubuntu 20.04.

Scroll to Top