TensorFlow is a free and open-source software library for machine learning. TensorFlow is used to train neural networks. It can be used across a range of tasks but has a particular focus on training and inference of deep neural networks. Tensorflow is a symbolic math library based on dataflow and differentiable programming. TensorFlow was developed by the Google Brain team for internal Google use. It was released under the Apache License 2.0 in 2015. On this articel we will discuss how to install TensorFlow on Linux Ubuntu 20.04 LTS operating system.
TensorFlow Installation on Ubuntu 20.04
On this article, we will explain how to install TensorFlow in a Python virtual environment which is running on Linux Ubuntu 20.04 LTS. A virtual environment enable us to have multiple different isolated Python environments on a single computer and install a specific version of a module on a per-project basis, without worrying that it will affect any other Projects.
Ubuntu 20.04 LTS Operating system with sufficient disk space
root or an ordinary user access who is having sudo privilege
Python 3.9 support requires TensorFlow 2.5 or later.
Python 3.8 support requires TensorFlow 2.2 or later.
pip 19.0 or later (requires manylinux2010 support)
TensorFlow Installation Steps :
Install the Python development environment on your system
Create a virtual environment (recommended)
Install the TensorFlow pip package
1. Install the Python development environment
1.1 Update Ubuntu 20.04 LTS system
On this stage, we will update our system to refresh our system pacakges. For this purpose we will submit the command line :
ramans@otodiginet:~$ sudo apt install python3-venv python3-dev
[sudo] password for ramans:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
libc-dev-bin libc6-dev libcrypt-dev libexpat1-dev libpython3-dev libpython3.8 libpython3.8-dev
libpython3.8-minimal libpython3.8-stdlib linux-libc-dev manpages-dev python-pip-whl
python3-distutils python3-lib2to3 python3.8 python3.8-dev python3.8-minimal python3.8-venv
glibc-doc python3.8-doc binutils binfmt-support
The following NEW packages will be installed:
libc-dev-bin libc6-dev libcrypt-dev libexpat1-dev libpython3-dev libpython3.8-dev linux-libc-dev
manpages-dev python-pip-whl python3-dev python3-distutils python3-venv python3.8-dev python3.8-venv
The following packages will be upgraded:
libpython3.8 libpython3.8-minimal libpython3.8-stdlib python3-lib2to3 python3.8 python3.8-minimal
6 upgraded, 15 newly installed, 0 to remove and 192 not upgraded.
Need to get 12.9 MB/19.1 MB of archives.
After this operation, 56.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
setting up python3-distutils (3.8.10-0ubuntu1~20.04) ...
Setting up libpython3.8:amd64 (3.8.5-1~20.04.3) ...
Setting up python3.8-venv (3.8.5-1~20.04.3) ...
Setting up libc6-dev:amd64 (2.31-0ubuntu9.2) ...
Setting up libexpat1-dev:amd64 (2.2.9-1build1) ...
Setting up python3-venv (3.8.2-0ubuntu2) ...
Setting up libpython3.8-dev:amd64 (3.8.5-1~20.04.3) ...
Setting up zlib1g-dev:amd64 (1:1.2.11.dfsg-2ubuntu1.2) ...
Setting up libpython3-dev:amd64 (3.8.2-0ubuntu2) ...
Setting up python3.8-dev (3.8.5-1~20.04.3) ...
Setting up python3-dev (3.8.2-0ubuntu2) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu3) ...
2. Create Virtual Environment
2.1 Create New Directory For VE
On this short tutorial, we will create an new directory called as : oto_tensor, then create a new Python3 environment on it. For this purpose we will submit the following command lines :
After TensorFlow installation was completed done, then we will verify it by submitting command :
$ python -c 'import tensorflow as tf; print(tf.version)'
(oto_venv) ramans@otodiginet:~/oto_tensor$ python -c 'import tensorflow as tf; print(tf.version)' 2021-06-10 17:13:35.391842: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory 2021-06-10 17:13:35.391889: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2.5.0
So far, we have reached the final step.
On this short tutorial, we have learnt how to install TensorFlow version 2.5.0 on Ubuntu 20.04 LTS operating system. I hope this article will be helpful.