Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Artificial Intelligence

How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04

by Cloudbooklet
7 months ago
in Artificial Intelligence, Compute Engine, Deep Learning, Google Cloud, Linux
Set Up Deep Learning With Nvidia, Cuda, Cudnn On Ubuntu
ShareTweetSendShare
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

Deep learning setup on your Ubuntu 22.04 system? Look no further than this comprehensive guide, which includes step-by-step instructions of Nvidia, Cuda, cuDNN, Anaconda

ADVERTISEMENT

Table of Contents

  1. System Requirements
  2. Update the System
  3. Verify GPU
  4. Install Pre-required Packages
  5. Install Kernel Headers
  6. Install NVIDIA Drivers
  7. Install CUDA Toolkit and cuDNN
    1. Install CUDA
    2. Install CUDNN
  8. Install Anaconda
  9. Create a New Conda Environment
  10. Activate the Conda Environment
  11. Install Deep Learning Frameworks
  12. Verify Your Installation
  13. Wrap Up!

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 architecture on Ubuntu 22.04, including key configurations like Nvidia driver, Cuda, cuDNN, Anaconda setups to ensure a successful installation.

System Requirements

This setup is tested on a virtual machine provisioned on Google Cloud Compute Engine with the below configurations.

ADVERTISEMENT
  1. GPU: Tesla T4
  2. CPU: N1-Standard2 (2vCPU 7.5GB RAM)
  3. OS: Ubuntu 22.04 (x86/64)
  4. Disk space: 50 GB
  5. Secure Boot: Disabled.

The approx. cost for this machine on US-Central would cost around $250/mo.

You might also like

Google Bard Extension

Google Bard Extensions: How to Link Your Gmail, Docs, Maps, and More to an AI Chatbot

4 mins ago
Validator Ai

Validator AI: The AI Powered Business Idea Validator

1 day ago

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

Verify GPU

Verify if you have the GPU using the below command.

ADVERTISEMENT
lspci | grep -i nvidia

If you have your GPU you can proceed with the following installation.

Output
00:04.0 3D Controller: NVIDIA Corporation TU104GL [Tesla T4] (rev a1)

In this guide I am having Nvidia Tesla T4 GPU.

ADVERTISEMENT

Install Pre-required Packages

Before installing Nvidia driver you need to make sure you have all pre-required packages installed.

sudo apt install build-essential

Install Kernel Headers

You can use the following command to install kernel headers for your operating system.

ADVERTISEMENT
sudo apt install linux-headers-$(uname -r)

Now you can proceed with the driver installation

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:

ADVERTISEMENT
sudo apt install nvidia-driver-530

Now you need to reboot.

sudo reboot

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

wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run
sudo sh cuda_12.1.1_530.30.02_linux.run

Follow the on screen instructions.

  1. Accept the license agreement by typing accept
  2. Unselect the driver and then choose Install by using the arrow keys and space bar to move and select or unselect. You should not have X mark in the driver
  3. Move the arrow key down to Install and click Enter.
Cuda Installation On Ubuntu
How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04 1

Wait for sometime for the installation to complete.

Now CUDA will get installed in /usr/local/cuda-12.1 location.

Symlink the directory.

sudo ln -snf /usr/local/cuda-12.1 /usr/local/cuda

Install CUDNN

To install cuDNN, you need to login to Nvidia website and download the tar.gz version using this official link.

Once downloaded extract the downloaded file and copy the necessary contents to the cuda directory.

tar -zvxf cudnn-linux-x86_64-8.9.0.131_cuda12-archive.tar.xz

cd cudnn-linux-x86_64-8.9.0.131_cuda12-archive

sudo cp include/cudnn.h /usr/local/cuda-12.1/include
sudo cp lib/libcudnn* /usr/local/cuda-12.1/lib64

sudo chmod a+r /usr/local/cuda-12.1/include/cudnn.h /usr/local/cuda-12.1/lib64/libcudnn*

Now you have CUDA and CUDNN installed.

Once the installation is complete, update the environment variables, and add the following lines to ~/.bashrc

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

Activate the environment variables:

source ~/.bashrc

You can check cuda version using the below command.

nvcc -V
Cuda Version
How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04 2

You can also check Nvidia driver installation status using the following command.

nvidia-smi

You will get an output similar to the below one.

Nvidia Driver Installation
How to Set Up Deep Learning with Nvidia, CUDA, cuDNN on Ubuntu 22.04 3

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:

You can update the below link using the latest version from the official anaconda website.

curl https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh --output anaconda.sh
bash anaconda.sh

Follow the on screen instructions.

In the final step you can safely answer Yes to initialize Anaconda3.

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 learning.py

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:

python learning.py

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.

Tags: AnacondaCUDANvidiaUbuntu
Share49Tweet31SendShare
Cloudbooklet

Cloudbooklet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

Chatgpt To Translate

How to Use ChatGPT to Translate Your Website or Blog

1 day ago
Fantasy Minecraft Servers

5 Best Fantasy Minecraft Servers in 2023

1 day ago
Ai Statistics And Trends

AI Statistics and Trends: What You Need to Know in 2023

1 day ago
Block Youtube Ads

How to Block YouTube Ads on Android TV in 2023 (6 Easy Methods)

1 day ago

Follow Us

Trending Articles

Ai Soulmate

5 Free AI Soulmate Maker: Create Your Perfect Match

September 18, 2023

Microsoft Unveils New Disc-Less Xbox Series X with Lift-to-Wake Controller

How to Delete Netflix Account Permanently

How to Become an AI Trainer: Skills, Salary, and Career Opportunities

AI Annotation Jobs: Everything You Need to Know

Best 10 AI Comic Generator: Create Comic book in Seconds

Popular Articles

Photo To Sketch

AI Photo to Sketch: Best Way to Turn Your Photos into Sketches

September 8, 2023

Winston AI: How to Check AI Plagiarism for Better SEO

Google Safe Search Settings: Blurred Explicit Images in Search Results

How to Become an AI Engineer in 2023: The Complete Guide

3 Ways to View Instagram Posts Without Account (2023 Guide)

10 Best Minecraft Server Hosting Providers in 2023

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.