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

Thiết lập và thay đổi MariaDB 10.4.x Root Password

Khác với những version trước đây, MariaDB 10.4 bản ổn định có thêm nhiều cải tiến. Một trong...
30/12/2020

How to Install and Configure Consul Server on Ubuntu 18.04

Consul is an open source service discovery tool which is based and built on Golang. It helps you discovering services application...
29/12/2020

[Snort] Hướng dẫn đẩy log snort lên graylog

Ở bài trước thì các bạn đã biết được cách làm sao để cài đặt được snort lên trên máy centos...
30/12/2020
Bài Viết

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

Dịch Vụ Xây Dựng Hệ Thống Peering Với Internet Exchange (IXP)
04/04/2025

Dịch Vụ Triển Khai VPN Site-to-Site & Remote Access
04/04/2025

Dịch Vụ Thiết Lập Hệ Thống Tường Lửa (Firewall)
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ảo Hóa & Cloud
04/04/2025

Dịch Vụ Triển Khai Hệ Thống Ceph
04/04/2025