How to Set Up Your Linux System for AI Development
In the previous article, we introduced the basics of AI and how it fits into the world of Linux. Now, it’s time to dive deeper and set up your Linux system to start building your first AI model.
Whether you’re a complete beginner or have some experience, this guide will walk you through installing the essential tools you need to get started on Debian-based systems.
System Requirements for Ubuntu 24.04
Before we begin, let’s make sure your system meets the minimum requirements for AI development.
- Operating System: Ubuntu 24.04 LTS (or newer).
- Processor: A 64-bit CPU with at least 2 cores (Intel Core i5 or AMD Ryzen 5 or better recommended for smooth performance).
- RAM: Minimum 4 GB of RAM (8 GB or more recommended for more intensive AI models).
- Storage: At least 10 GB of free disk space (SSD is highly recommended for faster performance).
- Graphics Card (Optional): A dedicated GPU (NVIDIA recommended for deep learning) with at least 4 GB of VRAM if you plan to use frameworks like TensorFlow or PyTorch with GPU acceleration.
Step 1: Install Python on Ubuntu
Python is the most popular programming language for AI development, due to its simplicity, powerful, and huge library of tools and frameworks.
Most Linux systems come with Python pre-installed, but let’s make sure you have the latest version. If Python is installed, you’ll see something like Python 3.x.x
.
python3 --version
If Python is not installed, you can easily install it using the package manager.
sudo apt update sudo apt install python3
Next, you need to install pip (python package manager), which will help you install and manage Python libraries.
sudo apt install python3-pip
Step 2: Install Git on Ubuntu
Git is a version control tool that allows you to track changes in your code and collaborate with others, which is essential for AI development because many AI projects are shared on platforms like GitHub.
sudo apt install git
Verify the installation by typing:
git --version
You should see something like git version 2.x.x
.
Step 3: Set Up a Virtual Environment in Ubuntu
A virtual environment helps you manage your projects and their dependencies in isolation, which means you can work on multiple projects without worrying about conflicts between different libraries.
First, make sure you have the python3-venv
package installed, which is needed to create a virtual environment.
sudo apt install python3-venv
Next, you need to create a new directory for your project and set up a virtual environment:
mkdir my_ai_project cd my_ai_project python3 -m venv venv source venv/bin/activate
After running the above commands, your terminal prompt should change, indicating that you’re now inside the virtual environment.
Step 4: Install AI Libraries on Ubuntu
Now that you have Python, Git, and Virtual Environment set up, it’s time to install the libraries that will help you build AI models.
Some of the most popular libraries for AI are TensorFlow, Keras, and PyTorch.
Install TensorFlow in Ubuntu
TensorFlow is an open-source library developed by Google that is widely used for machine learning and AI projects.
pip3 install tensorflow
Install Keras in Ubuntu
Keras is a high-level neural networks API, written in Python, that runs on top of TensorFlow.
pip3 install keras
Install PyTorch in Ubuntu
PyTorch is another popular AI library, especially for deep learning.
pip3 install torch
Step 5: Building Your First AI Model
Now that your system is ready, let’s build a simple AI model called a neural network using TensorFlow and Keras to classify handwritten digits from the famous MNIST dataset.
Create a new Python file called first_ai_model.py
and open it in your favorite text editor.
sudo nano first_ai_model.py
At the top of the file, add the following imports to import the necessary libraries:
import tensorflow as tf from tensorflow.keras import layers, models
Next, load the MNIST dataset, which contains 60,000 images of handwritten digits (0-9) to train our model.
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.mnist.load_data()
Preprocess the data to normalize the images to values between 0 and 1 by dividing by 255.
train_images, test_images = train_images / 255.0, test_images / 255.0
Build the model by creating a simple neural network with one hidden layer.
model = models.Sequential([ layers.Flatten(input_shape=(28, 28)), layers.Dense(128, activation='relu'), layers.Dense(10) ])
Compile the model by specifying the optimizer, loss function, and metrics for evaluation.
model.compile(optimizer='adam', loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), metrics=['accuracy'])
Train the model using the training data.
model.fit(train_images, train_labels, epochs=5)
Finally, test the model on the test data to see how well it performs.
test_loss, test_acc = model.evaluate(test_images, test_labels) print('Test accuracy:', test_acc)
Step 6: Run the AI Model
Once you’ve written the code, save the file and run it in your terminal:
python3 first_ai_model.py
The model will begin training, and after 5 epochs, it will display the test accuracy. The higher the accuracy, the better the model’s performance.
Congratulations, you’ve just built your first AI model!
Conclusion
In this guide, we covered how to set up your Linux system for AI development by installing Python, Git, and essential AI libraries like TensorFlow, Keras, and PyTorch.
We also walked through building a simple neural network to classify handwritten digits. With these tools and knowledge, you’re now ready to explore the exciting world of AI on Linux!
Stay tuned for more articles in this series, where we’ll dive deeper into AI development techniques and explore more advanced topics.
The above is the detailed content of How to Set Up Your Linux System for AI Development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.
