Artificial Intelligence Deep Learning

How to Set Up Deep Learning Architecture on Ubuntu 22.04

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

Deep learning is a cutting-edge technology that enables machines to learn and improve on their own. However, setting up a deep learning environment on your Ubuntu 22.04 system can be a daunting task for those who are new to the technology. In this article, we will walk you through the process of setting up deep learning on Ubuntu 22.04, including key configurations to ensure a successful installation.

Update the System

Before starting with the installation process, it is recommended to update the system with the latest patches and software updates. Run the following command to update your Ubuntu 22.04 system:

sudo apt update && sudo apt upgrade

Install NVIDIA Drivers

One of the most important steps to setting up deep learning on Ubuntu 22.04 is to install the appropriate NVIDIA drivers for your graphics card. To do this, open a terminal and run the following commands:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-driver-470

Install CUDA Toolkit and cuDNN

Next, you will need to install the CUDA Toolkit and cuDNN, which are essential for running deep learning frameworks such as TensorFlow and PyTorch. You can download the latest version of the CUDA Toolkit from the NVIDIA website, and cuDNN from the cuDNN website. Once you have downloaded the appropriate files, you can install them by running the following commands:

Install CUDA

sudo sh

Now, Update the environment variables, and add the following lines to ~/.bashrc

export PATH=/usr/local/cuda-11.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Activate the environment variables:

$ source ~/.bashrc

Install CUDNN

tar -zvxf cudnn-11.2-linux-x64-v8.1.0.77.tgz
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-11.2/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-11.2/lib64/
sudo chmod a+r /usr/local/cuda-11.2/lib64/libcudnn*

You can verify CUDA and CUDNN installation using the below command:

nvcc -V

Install Anaconda

Anaconda is a popular Python distribution that comes with many pre-installed libraries and tools used in deep learning. To install Anaconda, run the following commands:


Create a New Conda Environment

A Conda environment is a virtual environment that allows you to install and manage different versions of packages and libraries. To create a new Conda environment, run the following command:

conda create --name deep-learning

Activate the Conda Environment

After creating a new Conda environment, you need to activate it by running the following command:

conda activate deep-learning

Install Deep Learning Frameworks

Now that you have installed the necessary drivers and tools, you can install the deep learning frameworks of your choice, such as TensorFlow or PyTorch. You can install these frameworks using pip, the Python package manager, as shown below:

pip3 install tensorflow
pip3 install keras
pip install torch

Verify Your Installation

To test the installation, you can run a sample script that uses TensorFlow, Keras, and PyTorch. Create a new Python file and paste the following code:

sudo nano

Paste the below code and save the file.

import tensorflow as tf
import keras
import torch
print("TensorFlow version:", tf.version)
print("Keras version:", keras.version)
print("PyTorch version:", torch.version)

Execute the file using the following command:


If everything is installed correctly, you should see the versions of TensorFlow, Keras, and PyTorch printed on the screen.

Wrap Up!

In conclusion, setting up a deep learning environment in Ubuntu 22.04 can be a challenging task, but by following the steps outlined above, you can ensure a smooth and successful installation. By installing the necessary drivers and tools, and then installing your preferred deep learning frameworks, you will be well on your way to developing and running your own deep learning models.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.