Skip to content

Here are the steps to install CUDA v11.36 and cuDNN v8.5 on Ubuntu 22.04

License

Notifications You must be signed in to change notification settings

c1ph3r-fsocitey/CUDA-CUDNN-install-Ubuntu22.04

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Steps for Installation of CUDA v11.36 and cuDNN 8.5 Drivers on Ubuntu 22.04

Step 1: Check if GPU is CUDA Compatible

lspci | grep -i nvidia

Step 2: Remove previous installations

sudo apt-get purge nvidia*
sudo apt remove nvidia-*
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt-get autoremove && sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*

Step 3: System update

sudo apt-get update
sudo apt-get upgrade

Step 4: (Recommended way)

You can also use the GUI provided by Ubuntu to install the Nvidia Drivers

In Ubuntu search for "Additional Drivers", and install the one that's recommended

Additional_Drivers.webm

Alternative to Step 4:(Install Nvidia Drivers with dependencies)

sudo apt install libnvidia-common-515
sudo apt install libnvidia-gl-515
sudo apt install nvidia-driver-515

Step 5: PreInstall CUDA by fetching keys

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /"

Step 6: Update again

sudo apt update

Step 7: Install CUDA 11.7

sudo apt install cuda-11-7 

Step 8: Path Setup

echo 'export PATH=/usr/local/cuda-11.7/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig

Step 9: Download cuDNN for CUDA v11.7

Use the following link to register and download the cuDNN Driver here: https://developer.nvidia.com/rdp/cudnn-archive
Download the one mentioned for CUDA v11.x

Nvidia_cuDNN.webm

Step 10: Install the cuDNN .deb file

After downloading the cuDNN deb file, navigate to the downloads folder

cd Downloads

And use the following command to install it

sudo apt install ./<name_of_file.deb>

Step 11: Copy file paths

use the following commands to copy the files to CUDA toolkit directory

sudo cp -P cuda/include/cudnn.h /usr/local/cuda-11.7/include
sudo cp -P cuda/lib/libcudnn* /usr/local/cuda-11.7/lib64/
sudo chmod a+r /usr/local/cuda-11.7/lib64/libcudnn*

Step 12: Verify the installation

nvidia-smi
nvcc -V

Expected Output for nvidia-smi

image

Expected output for nvcc -V

image

To install PyTorch

pip3 install torch torchvision torchaudio

Verify PyTorch installation

use the following code in a python file and run it.
If it outputs "True" it is sucessfully installed

import torch
torch.cuda.is_available()

image

To Install Tensorflow

python3 -m pip install tensorflow==2.13.*

Verify installation

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

If the output is something like this, it shows TensorFlow has been installed sucessfully for GPU
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

image

Releases

No releases published

Packages

No packages published