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
Table of Contents
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.
This setup is tested on a virtual machine provisioned on Google Cloud Compute Engine with the below configurations.
GPU: Tesla T4
CPU: N1-Standard2 (2vCPU 7.5GB RAM)
OS: Ubuntu 22.04 (x86/64)
Disk space: 50 GB
Secure Boot: Disabled.
The approx. cost for this machine on US-Central would cost around $250/mo.
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.
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:
sudo apt install nvidia-driver-530
Now you need to 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:
sudo sh cuda_12.1.1_530.30.02_linux.run
Follow the on screen instructions.
Accept the license agreement by typing accept
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
Move the arrow key down to Install and click Enter.
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
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-188.8.131.52_cuda12-archive.tar.xz
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
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
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.
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.
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.