TensorFlow is a popular open-source machine learning library developed by the Google Brain team. It has become the go-to library for researchers and developers working on various ML and AI projects. In this blog post, we’ll walk you through the process of how to install TensorFlow on Rocky Linux, a community-driven, enterprise-ready Linux distribution.
Before you begin, make sure you have the following:
- A Rocky Linux system.
- Sudo privileges.
- Python 3.6 or later installed on your system. You can follow our guide on how to install Python on Rocky Linux if you haven’t installed it yet.
How to Install TensorFlow on Rocky Linux
Update Your System
First, update your system to ensure you have the latest packages and dependencies installed:
sudo dnf update -y
Install Required Libraries and Dependencies
Some libraries and dependencies are required for TensorFlow to function correctly. Install the necessary packages with the following command:
sudo dnf install -y gcc gcc-c++ git unzip wget make cmake3
Set Up a Python Virtual Environment
It’s recommended to create a virtual environment for TensorFlow to avoid any conflicts with the system packages. You can use
venv to create a virtual environment as follows:
python3 -m venv tensorflow_env
Activate the virtual environment with the following command:
Install TensorFlow on Rocky Linux
Now that you have the virtual environment activated, you can install TensorFlow using
pip install --upgrade pip pip install tensorflow
This will install the latest version of TensorFlow available. If you need a specific version, you can specify it using the following syntax:
pip install tensorflow==<version>
<version> with the desired version number.
Verify TensorFlow Installation
To verify that TensorFlow has been installed successfully, run the following commands:
python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
If the installation is successful, you should see an output similar to this:
tf.Tensor(-107.40114, shape=(), dtype=float32)
The exact value may vary due to the random nature of the generated tensor.
Deactivate the Virtual Environment (Optional)
After you have finished working with TensorFlow, you can deactivate the virtual environment by running the following command:
This will return you to the system’s default Python environment.
Congratulations! You have successfully installed TensorFlow on your Rocky Linux system. Now you can start working on your machine learning and artificial intelligence projects using this powerful library. If you need more information about setting up and configuring other software on Rocky Linux, feel free to explore our other guides such as how to install MySQL, how to install MariaDB, and how to set up an OpenVPN server.
TensorFlow is a versatile library, supporting various applications like natural language processing, computer vision, and reinforcement learning. Keep in mind that TensorFlow can take advantage of GPU acceleration for faster computations. To do so, you’ll need to install the GPU version of TensorFlow along with the required NVIDIA CUDA libraries and cuDNN. You can follow the official TensorFlow GPU support documentation for more information on setting up TensorFlow with GPU support.
Now that you have TensorFlow installed, you can start exploring its features and capabilities. If you are new to TensorFlow, consider working through some TensorFlow tutorials to familiarize yourself with the library and learn how to build various machine learning models. Additionally, you can refer to the official TensorFlow documentation for more information on different APIs and functionalities.