logo of Akmatori
12.06.2024

Installing CUDA Drivers on Ubuntu 22.04

head-image

Introduction

Installing CUDA drivers on Ubuntu 22.04 is straightforward. Follow this step-by-step guide for a smooth installation.

Step 1: Update Your System

Start by updating your system. Open the terminal and run:

sudo apt update
sudo apt upgrade -y

Keeping your system updated ensures security and stability.

Step 2: Install Dependencies

Next, install the required dependencies with the following command:

sudo apt install build-essential dkms

These packages help in building and managing kernel modules.

Step 3: Add NVIDIA Repository

Add the NVIDIA package repository to your system. This step is crucial for downloading CUDA:

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 4: Install CUDA Toolkit

Now, install the CUDA toolkit. This step also installs the necessary drivers:

sudo apt update
sudo apt install cuda -y

This command installs CUDA and its components.

Step 5: Reboot Your System

After installation, reboot your system to load the new drivers:

sudo reboot

Rebooting ensures the new drivers are active.

Step 6: Verify Installation

Once your system reboots, verify the installation. Check if the drivers and CUDA toolkit are properly installed:

nvidia-smi
nvcc --version

If nvidia-smi shows GPU information and nvcc --version displays the CUDA version, your installation is successful.

Optional: Set Environment Variables

Setting environment variables can help in locating CUDA tools. Add the following lines to your ~/.bashrc or ~/.zshrc file:

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

Source the file to apply the changes:

source ~/.bashrc  # or source ~/.zshrc if you use zsh

Conclusion

Installing CUDA drivers on Ubuntu 22.04 is simple. Follow these steps to ensure a smooth installation. Keep your system updated and verify each step for success. With these drivers, you can harness the power of CUDA on your NVIDIA card.

While you optimize your system with CUDA, consider enhancing your network performance with Akmatori - A Globally Distributed TCP/UDP Load Balancer. Akmatori ensures efficient load balancing across your servers worldwide. Try Akmatori today to improve your network's reliability and performance.

Feel free to share this guide with others who might find it helpful. Happy computing!

Maximize your website or application's performance and reliability!