Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to install TensorFlow on CentOS 8

Shulou Source: shulou.com Published: 2022-06-01 23:30:34 10月05日 Update

This article will explain in detail how to install TensorFlow on CentOS 8. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Install TensorFlow on CentOS

Unlike other Linux distributions, Python is not installed on the default CentOS 8. To install Python3 on CentOS 8, run the following command on the terminal as user root or sudo:

Sudo dnf install python3

The above command will install Python 3.6and pip. To run Python 3, you need to type python3 and type pip3 to run pip.

Starting with Python 3.6, the recommended way to create a virtual environment is to use the venv module.

Change to a directory that you use to store your TensorFlow project. It can be your home directory or any other directory where the user has read and write access.

Create a new directory for the TensorFlow project and change to the directory:

Mkdir tensorflow_project cd tensorflow_project

In this directory, run the following command to create a virtual environment:

Python3-m venv venv

The above command creates a directory called venv that contains the Python binaries, the pip standard Python library, and other support files. You can name the folder with any name you want.

To start with the virtual environment, type the following command to activate it:

Source venv/bin/activate

Once activated, the bin directory of the virtual environment will be added to the front of the $PATH environment debate. Of course, your shell prompt will change and it will display the name of the virtual environment you are using. In this example, venv is displayed.

TensorFlow installation requires pip version 19 or higher. Run the following command to upgrade pip to the latest version:

Pip install-upgrade pip

Now that the virtual environment has been created and activated, install the TensorFlow library using the following command:

Pip install-upgrade tensorflow if you have a stand-alone NVIDIA GPU and you need to use its processing power, do not use the `tensorflow` package, but install the `tensorflow` package, which includes GPU support. In this virtual environment, you can use the command `pip3` to replace `pip3` and `python` to replace `python3`

To verify the installation, run the following command, which will print the version number of TensorFlow:

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

As of this writing, the latest stable version of TensorFlow is 2.1.0:

2.1.0

Your TensorFlow version may not be the same as shown.

If you are new to TensorFlow, browse the Get Started with TensorFlow page and learn how to build your first ML application. You can also clone TensorFlow Models or TensorFlow-Examples from Github and browse and test the TensorFlow example.

Once you have finished your work, unlock the environment, type deactivate, and you will return to normal shell.

Deactivate

That's all! You have successfully installed TensorFlow, and you can start using it.

This is the end of the article on "how to install TensorFlow on CentOS 8". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Commands environment directory facet run version article input file activation name more user project switch support browse good practical successful Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Xiaomi Microsoft Shulou Technology OPPO Reno