Install and Use TensorFlow on CentOS 8 - Step by step guide ?

Install and Use TensorFlow on CentOS 8 - Step by step guide ?

TensorFlow is Google's open-source platform for machine learning designed to simplify the process of implementing machine-learning models.
Researchers, data scientists, and developers use this end-to-end library for numerical computation. TensorFlow runs on multiple CPUs, GPU, as well as mobile operating systems.
It can be installed system-wide, in a Python virtual environment, as a Docker container, or with Anaconda. Also, large companies like Airbus, Intel, Twitter, PayPal, and Lenovo using TensorFlow. 
Here at Fixwebnode , as part of our Server Support Services , we regularly help our Customers to perform related Python Packages queries.
In this context, we shall look into how to install TensorFlow in a Python virtual environment on CentOS 8.

Steps to Install TensorFlow on CentOS

You need to Perform the following steps to install TensorFlow on CentOS.

1. Perform System Update         
First, let's start by ensuring your system is up-to-date:

$ sudo dnf update     

	
	

 

2. Install Python 3 and venv 

By default Python is not installed on CentOS 8 system. Run the following command to install Python 3 on CentOS 8 machine:

$ sudo dnf install python3 
	
	

It will install Python 3 and pip. To run Python 3, you need to type python3 explicitly, and to run pip type pip3.

The recommended way to create a virtual environment is to use the venv module.

 

3. Create Virtual Environment   
Here, you have to navigate to the directory where you would like to store your Python 3 virtual environments. Make sure the user has read and write permissions of that directory.
Create a new directory for the TensorFlow project and cd into it:

$ mkdir tensorflow_demo     
$ cd tensorflow_demo 

To create the virtual environment, run the following command:

$ python3 -m venv venv

The above command will create a directory named venv and it contains a clone of the Python binary, the standard Python library, and other supporting files, the Pip package manager.
To activate it run the activate script:

$ source venv/bin/activate 

Once activated, the virtual environment’s bin directory will be added at the beginning of the system $PATH variable . Also, the shell’s prompt will change, and it will show the name of the virtual environment you’re currently in. In this example, that is (venv).
The pip version 19 or higher is required for TensorFlow installation. To upgrade pip to the latest version run the following command:
$ pip install --upgrade pip


4. Install TensorFlow on the system
Here, the virtual environment is activate and we can install the TensorFlow package:
$ pip install --upgrade tensorflow

 

How to confirm TensorFlow Installation ?

You can Verify the installation by running the below command:

$ python -c 'import tensorflow as tf; print(tf.__version__)'
	
	


This will display the version of TensorFlow installed on the system.

[Need assistance in fixing CentOS Linux system issues? We can help you . ]


Conclusion

This article covers how to install TensorFlow inside a virtual environment on CentOS 8. In fact, TensorFlow is an end-to-end open-source machine learning platform used for machine learning and deep learning applications.


icon

Sign up to our Newsletter

...and get one free support ticket.