Install and Use TensorFlow on Ubuntu 20.04

28/12/2020
Chưa phân loại

TensorFlow is an open-source library built by Google to perform machine learning-oriented tasks. It has been used by various popular platforms like PayPal, Twitter, and Lenovo. TensorFlow is now widely used in cutting edge technologies based systems.

The TensorFlow installation on Ubuntu 20.04 is described in this article.

It is best practice to create a virtual environment and install TensorFlow. The virtual environment provides a different Python environment to developers and resolves the libraries and version dependencies issues.

TensorFlow installation on Ubuntu 20.04

Follow the below-given steps to install TensorFlow on Ubuntu 20.04:

Step 1: Verify Python 3.8 installation

Python installation is a pre-requisite for TensorFlow. Python 3.8 is pre-installed in Ubuntu 20.04. Run the following command to verify the installation of Python on your Ubuntu 20.04:

Python 3.8.5 is already installed on Ubuntu 20.04.

Step 2: Install Python virtual environment (venv) module

The next step is to install the Python 3 virtual environment using the venv module. The venv module is part of the package  python3 venv and can be installed with the  command:

$ sudo apt install python3-venv python3-dev

After the successful installation of the venv module, create a virtual environment in the next step.

Step 3: Create a Python 3 virtual environment

Your home directory must have a virtual environment inside. In case you want to create the virtual environment into a new directory, then run the following command to create a new directory named tensor_environment:

$ mkdir tensor_environment

Now use the following command to navigate to the newly created directory:

Now it is ready to create a virtual environment. The command’s syntax for creating a virtual environment is as follows:

$ python3 -m venv <virtual_environment_name>

You can write any virtual environment name. We are creating a tensor_venv virtual environment using the following command:

$ python3 -m venv tensor_venv

The virtual environment named tensor_venv is created successfully.

Before using a virtual environment, we need to activate it as follows:

source tensor_venv/bin/activate

The virtual environment name has appeared in the parenthesis on the command line. It is an indication that the virtual environment is activated successfully.

Step 4: Upgrade to pip version 19 or higher

PIP is a Python package manager that is used to install and maintain the Python packages. The TensorFlow can be installed using pip. The PIP version 19 or higher is required to install the TensorFlow. Upgrade to PIP version 19 or higher using the following command:

$ pip install –upgrade pip

Alright! The PIP is upgraded to version 20.3.1 successfully.

Step 5: Install TensorFlow using PIP

It’s time to install the TensorFlow using pip. Run the following command to do so:

$ pip install –upgrade TensorFlow

The TensorFlow installation will take a couple of minutes.

Step 6: Verify the TensorFlow installation

Upon successful TensorFlow installation, verify the installation using the following command:

$ python -c ‘import TensorFlow as tf; print(tf.__version__)’

The above command displays the TensorFlow version installed on your Ubuntu 20.04.

Conclusion

TensorFlow is now widely used in machine learning projects. It is a very efficient library and developed by Google. This guide demonstrates the installation procedure of TensorFlow on Ubuntu 20.04.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Android Studio Ubuntu Tutorial

What is Android Studio? It is the officially recognized Integrated Development environment (IDE) used to make Android apps....
28/12/2020

Guide to Installing Linux on a Mac

The following article is a guide to installing Linux on a Mac PC. Most of the time we opt for Linux operating systems but...
29/12/2020

Bash `pushd` command

The Linux users may need to switch between many directories for doing a particular task and it is a time consuming task...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Check proxy trên trang nào chuẩn nhất❓
01/11/2023

Thuê Proxy chạy Google Ads / Cần chú ý gì khi chọn proxy và email chạy G.G ads?
12/10/2023

Thuê proxy 4G ở đâu uy tín, giá rẻ, chất lượng?
05/10/2023

Vì sao cần thuê proxy xoay? Địa chỉ cung cấp proxy xoay uy tín
05/10/2023

Thuê proxy v6 kéo view Youtube ở đâu uy tín, chất lượng?
05/10/2023