Artificial Intelligence (AI) is revolutionizing technology, enabling machines to perform tasks such as image recognition, natural language processing, and decision-making. For those new to AI development, RHEL, CentOS, RockyLinux, and AlmaLinux are excellent choices due to their stability, enterprise-grade features, and wide adoption in the industry.
This guide will walk you through setting up an AI development environment on these distributions.
Prerequisites
Before starting, ensure you have the following:
- Root or sudo Access: You’ll need administrative privileges to install packages.
- Python: The primary language for AI development.
- Basic Command Line Knowledge: Familiarity with terminal commands is essential.
Step 1: Update Your System
Keeping your system up-to-date minimizes compatibility issues. Use the following command:
sudo dnf update -y
For older systems using yum
, replace dnf
with yum
.
Step 2: Install Python
Most AI frameworks require Python 3. Check if Python is installed:
python3 --version
If it’s not installed, install Python 3 and pip
:
sudo dnf install python3 python3-pip -y
Verify the installation:
python3 --version
pip3 --version
Step 3: Install Development Tools
To compile and install some AI packages, you’ll need development tools:
sudo dnf groupinstall "Development Tools" -y
sudo dnf install gcc gcc-c++ make -y
Step 4: Install AI Libraries
Set Up a Virtual Environment
Using virtual environments isolates dependencies for each project:
python3 -m venv myenv
source myenv/bin/activate
Install TensorFlow
Install TensorFlow for machine learning and deep learning:
pip install tensorflow
Install PyTorch
For PyTorch, use the following command to get the correct version based on your CUDA setup:
pip install torch torchvision
Install Scikit-learn
Scikit-learn is great for traditional machine learning tasks:
pip install scikit-learn
Install Pandas and NumPy
These libraries are essential for data manipulation and numerical computations:
pip install pandas numpy
Install Jupyter Notebook (Optional)
Jupyter Notebook is widely used for interactive AI development:
pip install notebook
jupyter notebook
Step 5: Install GPU Drivers (Optional)
If your system has an NVIDIA GPU, installing drivers and CUDA will significantly accelerate model training.
Install NVIDIA Drivers
First, detect your NVIDIA GPU:
lspci | grep -i nvidia
Then, add the NVIDIA repository:
sudo dnf config-manager --add-repo=http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
sudo dnf clean all
Install the driver:
sudo dnf install nvidia-driver-latest-dkms
Reboot the system:
sudo reboot
Install CUDA and cuDNN
Download and install CUDA and cuDNN from the NVIDIA website. Follow the installation guide provided for your RHEL-based system.
Step 6: Test Your Setup
Test TensorFlow:
python3
>>> import tensorflow as tf
>>> print(tf.__version__)
Test PyTorch:
python3
>>> import torch
>>> print(torch.__version__)
If both print version numbers without errors, your setup is complete.
Step 7: Start Building AI Models
Here’s a simple example of a neural network using TensorFlow and Keras:
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
# Define a simple model
model = Sequential([
Dense(64, activation='relu', input_shape=(784,)),
Dense(10, activation='softmax')
])
# Compile the model
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
# Display the model summary
model.summary()
You can train this model using datasets like MNIST or CIFAR-10.
Conclusion
You’ve successfully set up an AI development environment on RHEL, CentOS, RockyLinux, or AlmaLinux. With Python, TensorFlow, PyTorch, and Jupyter Notebook installed, you’re ready to start building and training AI models.
These enterprise-grade distributions provide a robust platform for AI development, whether for research, experimentation, or deployment in production environments. Happy coding!