Skip to content

Kshitij-M/complete_gpu_setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

CUDA, cuDNN, and PyTorch Setup Guide for Ubuntu 🐧

Welcome to the ultimate setup guide for CUDA 11.8, cuDNN, and PyTorch on Ubuntu. Follow these instructions to get your machine learning environment up and running with GPU acceleration!

Prerequisites 📋

  • Ubuntu Operating System
  • NVIDIA GPU (CUDA-Compatible)
  • Internet Connection

Step-by-Step Installation Guide 🚀

Step 1: Verify CUDA-Compatible GPU

Before starting, ensure that you have a CUDA-compatible NVIDIA GPU.

lspci | grep -i nvidia

Step 2: Clean Up Previous NVIDIA Installations

Remove any existing NVIDIA drivers and CUDA installations to prevent conflicts.

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

Keep your system up-to-date for better compatibility.

sudo apt-get update
sudo apt-get upgrade

Step 4: Install Required Packages

Install the necessary packages for NVIDIA drivers and CUDA toolkit.

sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

Step 5: Add NVIDIA PPA Repository

Access the latest NVIDIA drivers through this repository.

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

Step 6: Install NVIDIA Drivers

Before installing the drivers, identify the recommended driver for your GPU.

  1. Install necessary utilities:

    sudo apt-get install alsa-utils
    sudo apt install ubuntu-drivers-common
  2. Check the recommended drivers:

    ubuntu-drivers devices

    This will output a list of drivers with one marked as recommended.

  3. Install the recommended driver:

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

Step 7: Install CUDA Toolkit 11.8

Download and install the CUDA Toolkit.

wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-11-8

Step 8: Set Environmental Variables

Update your PATH and LD_LIBRARY_PATH variables.

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

Step 9: Install cuDNN v8.9.7

Download and install cuDNN. Make sure to register at NVIDIA's website before downloading. [https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/]

CUDNN_TAR_FILE="cudnn-linux-x86_64-8.9.7.29_cuda11-archive.tar.xz"
wget [YOUR CUDNN DOWNLOAD LINK]
tar -xvf ${CUDNN_TAR_FILE}
sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

Step 10: Reboot Your System for Sync 🖥️

After installing the drivers and CUDA, reboot your system to ensure the drivers are properly synchronized with the GPU hardware.

sudo reboot

Step 11: Verify NVIDIA Driver and CUDA Installation

Check if NVIDIA drivers and CUDA are installed correctly.

nvidia-smi
nvcc -V

Step 12: Install PyTorch

Finally, install PyTorch with CUDA support.

pip3 install --force-reinstall torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip3 install --force-reinstall torch-cluster torch-geometric torch-scatter torch-sparse torch-spline-conv -f https://data.pyg.org/whl/torch-1.x.x+cu118.html

🎉 Congratulations!

You have successfully set up CUDA, cuDNN, and PyTorch on your Ubuntu system. Start building your amazing machine learning projects!


Note: Always ensure you have the correct versions and your system meets all requirements. Happy coding! 🚀💻

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages