This tutorial will show you how to install TensorFlow on Rocky Linux. According to their site, TensorFlow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML powered applications.
Install TensorFlow on Rocky Linux
There are various ways in which you can install TensorFlow;
- Install using Python PIP
- Install via Docker
- Build and install from the source.
We will only discuss the PIP installation method in this guide. For other methods refer to the documentation.
Before you can proceed with installation, be sure to check on hardware, system and software requirements.
Install TensorFlow using Python PIP
To install TensorFlow using Python PIP;
Install Python 3.x
TensorFlow requires Python 3.7-3.10.
Confirm the current Python version installed.
python3 -V
Sample output;
Python 3.9.7
If your version is lower than 3.7, you can install the required version using the package manager. Refer to the link below;
Install Python on Rocky Linux 8
Install PIP on Rocky Linux
pip version 19.0 or higher is required. You can install PIP on Rocky Linux using the command below;
sudo dnf install python3-pip
Install Required Python Libraries and Virtual Environment
Run the command below to install required Python libraries and virtual environment.
sudo dnf install python3-{virtualenv,devel}
Create TensorFlow Virtual Environment
Next, run the command below to install TensorFlow;
mkdir ~/tensorflow && cd ~/tensorflow
Create virtual environment, in this case we called our virtual environment, tensorflow_venv. You can use any name!
python3 -m venv tensorflow_venv
Activate the virtual environment created;
source ./tensorflow_venv/bin/activate
You will see the shell prompt change;
(tensorflow_venv) [kifarunix@rocky-linux ~]$
Upgrade PIP;
pip install --upgrade pip
Verify installed PIP version;
pip3.9 --version
pip 22.1.1 from /home/kifarunix/.local/lib/python3.9/site-packages/pip (python 3.9)
Install TensorFlow using PIP
Within the virtual environment, run the command below to install TensorFlow using PIP.
pip3.9 install --upgrade tensorflow
Check installed version of TensorFlow;
python3 -c 'import tensorflow as tf;print(tf.version.VERSION)'
Sample output;
2.9.1
You can now use TensorFlow. Refer to the documentation for more information.
You can deactivate the virtual environment using the command;
deactivate
You should see the shell prompt change.
And that is all on how TensorFlow can be installed on Rocky Linux.