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

Installing WINE on Debian 10 Buster

Introduction Resolving dependencies to install WINE on Debian 10 Buster Getting, installing and configuring WINE Running...
29/12/2020

How to install Babe Music Player – A New Tiny Qt Music Player

Babe Music Player is a promising new tiny Qt Babe music player to keep your favorite songs at hand. Babe will handle all...
28/12/2020

Managing Docker Volumes using Docker Compose

Purpose of Docker Volumes Docker containers are meant to be a drop-in replacement for applications. They are meant to be...
29/12/2020
Bài Viết

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

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024