Artificial Intelligence (AI) is one of the most exciting and rapidly evolving fields in technology today. With AI, machines are able to perform tasks that once required human intelligence, such as image recognition, natural language processing, and decision-making.

If you’re a beginner and want to dive into AI development, Linux is an excellent choice of operating system, as it is powerful, flexible, and widely used in the AI community.

In this guide, we’ll walk you through the process of setting up an AI development environment on your Ubuntu system.

What You Need to Get Started

Before you begin, let’s go over the essentials that you’ll need to set up an AI development environment on Linux:

  • Basic Command Line Knowledge: You should have some familiarity with the Linux terminal and basic commands, as you’ll need to run commands in it.
  • Python: Python is the most popular language for AI development, as most AI libraries and frameworks are written in Python, so it’s essential to have it installed.

Once you have these ready, let’s begin setting up your environment.

Step 1: Update Your System

The first step in setting up any development environment is to ensure that your system is up-to-date, which will ensure that all the software packages on your system are the latest versions and that you don’t run into any compatibility issues.

To update your system, open your terminal and run the following command:

sudo apt update && sudo apt upgrade -y

Once this process is complete, your system is ready for the installation of AI tools.

Step 2: Install Python in Ubuntu

Python is the go-to language for AI development and most AI frameworks such as TensorFlow and PyTorch, are built with Python, so it’s essential to have it installed on your system.

To check if Python is already installed, run:

python3 --version

If Python is installed, you should see a version number, such as Python 3.x.x. If it’s not installed, you can install it by running:

sudo apt install python3 python3-pip -y

Once Python is installed, you can verify the installation by running:

python3 --version

You should see the Python version number displayed.

Step 3: Install AI Libraries in Ubuntu

With Python installed, we now need to install the AI libraries that will help you build and train machine learning models. The two most popular AI libraries are TensorFlow and PyTorch, but there are others as well.

If you’re working on multiple AI projects, it’s a good idea to use virtual environments, as it allows you to isolate the dependencies for each project, so they don’t interfere with each other.

sudo apt install python3-venv
python3 -m venv myenv
source myenv/bin/activate

1. Install TensorFlow in Ubuntu

TensorFlow is one of the most widely used AI frameworks, particularly for deep learning, which provides tools for building and training machine learning models.

To install TensorFlow, run the following command:

pip3 install tensorflow

2. Install PyTorch in Ubuntu

PyTorch is another popular AI framework, especially known for its ease of use and dynamic computational graph, which is widely used for research and prototyping.

To install PyTorch, run:

pip3 install torch torchvision

3. Install Keras in Ubuntu

Keras is a high-level neural networks API that runs on top of TensorFlow, which makes it easier to build and train deep learning models by providing a simple interface.

To install Keras, run:

pip3 install keras

Keras is included with TensorFlow 2.x by default, so if you’ve already installed TensorFlow, you don’t need to install Keras separately.

4. Install Scikit-learn

For machine learning tasks that don’t require deep learning, Scikit-learn is a great library, which provides tools for classification, regression, clustering, and more.

To install it, run:

pip3 install scikit-learn

5. Install Pandas and NumPy in Ubuntu

Pandas and NumPy are essential libraries for data manipulation and analysis, as they are used for handling datasets and performing mathematical operations.

To install them, run:

pip3 install pandas numpy

Step 4: Install Jupyter Notebook (Optional)

Jupyter Notebook is a web-based tool that allows you to write and execute Python code in an interactive environment and it is widely used in AI development for experimenting with code, running models, and visualizing data.

To install Jupyter Notebook, run:

pip3 install notebook

After installation, you can start Jupyter Notebook by running:

jupyter notebook

This will open a new tab in your web browser where you can create new notebooks, write code, and see the output immediately.

Step 5: Install GPU Drivers (Optional for Faster AI Development)

If you have a compatible NVIDIA GPU on your system, you can use it to speed up the training of AI models, especially deep learning models, require a lot of computational power, and using a GPU can drastically reduce training time.

To install the necessary GPU drivers for NVIDIA cards, run:

sudo apt install nvidia-driver-460

After the installation is complete, restart your system to apply the changes.

You also need to install CUDA (Compute Unified Device Architecture) and cuDNN (CUDA Deep Neural Network library) to enable TensorFlow and PyTorch to use the GPU.

You can find the installation instructions for CUDA and cuDNN on NVIDIA’s website.

Step 6: Test Your Setup

Now that you have installed Python, the necessary AI libraries, and optionally set up a virtual environment and GPU drivers, it’s time to test your setup.

To test TensorFlow, open a Python interpreter by typing:

python3

Then, import TensorFlow and check its version:

import tensorflow as tf
print(tf.__version__)

You should see the version number of TensorFlow printed on the screen. If there are no errors, TensorFlow is installed correctly.

Next, test PyTorch:

import torch
print(torch.__version__)

If both libraries print their version numbers without any errors, your setup is complete.

Step 7: Start Building AI Models

With your environment set up, you can now start building AI models. Here’s a simple example of how to create a basic 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'])

# Summary of the model
model.summary()

This code defines a simple neural network with one hidden layer and an output layer for classification. You can train this model using datasets like MNIST (handwritten digits) or CIFAR-10 (images of objects).

Conclusion

Congratulations! You’ve successfully set up your AI development environment on Ubuntu with Python, TensorFlow, PyTorch, Keras, and Jupyter Notebook, you now have all the tools you need to start building and training AI models.

As you continue your journey into AI, you can explore more advanced topics such as deep learning, reinforcement learning, and natural language processing. There are many online resources, tutorials, and courses available to help you learn and improve your skills.

Remember, AI development is an exciting field with endless possibilities. Whether you want to build self-driving cars, create intelligent chatbots, or analyze big data, the skills you develop in AI will be valuable in many areas of technology.

Happy coding, and enjoy your AI journey!

Similar Posts