CUDA (Compute Unified Device Architecture) is a parallel computing platform and programming model developed by NVIDIA. It allows developers to use NVIDIA GPUs for general-purpose processing. If you’re running Ubuntu 24.04 Noble Numbat and need to leverage CUDA for your projects, this guide will help you install and configure it correctly.
Prerequisites
Before we start, ensure you have the following:
- A system running Ubuntu 24.04 Noble Numbat.
- An NVIDIA GPU that supports CUDA.
- A user account with sudo privileges.
- Basic knowledge of using the terminal.
Step 1: Update Your System
First, make sure your system is up-to-date by running the following commands:
$ sudo apt update
$ sudo apt upgrade -y
Step 2: Install NVIDIA Drivers
To use CUDA, you need the appropriate NVIDIA drivers. You can install them from the official NVIDIA repository:
-
Add the NVIDIA package repository:
$ sudo apt install ubuntu-drivers-common && sudo add-apt-repository ppa:graphics-drivers/ppa && sudo apt update
-
Install the recommended driver:
$ sudo ubuntu-drivers autoinstall
-
Reboot your system to apply the changes:
$ sudo reboot
-
Verify the installation:After rebooting, verify the installation by running:
$ nvidia-smi
You should see a table with information about your GPU.
Step 3: Install CUDA Toolkit
-
Download the CUDA Toolkit: Visit the NVIDIA CUDA Toolkit download page and select the appropriate version for Ubuntu 24.04. Download the
.deb
file. Alternatively, you can download it via the terminal:
$ wget https://developer.download.nvidia.com/compute/cuda/12.0.1/local_installers/cuda-repo-ubuntu2404-12-0-local_12.0.1-1_amd64.deb
-
Install the CUDA repository package:
$ sudo dpkg -i cuda-repo-ubuntu2404-12-0-local_12.0.1-1_amd64.deb && sudo cp /var/cuda-repo-ubuntu2404-12-0-local/cuda-*-keyring.gpg /usr/share/keyrings/
-
Install CUDA:
$ sudo apt update && sudo apt install cuda
-
Reboot your system again:
$ sudo reboot
Step 4: Set Up Environment Variables
After installing CUDA, you need to set up the environment variables. Add the following lines to your ~/.bashrc
file:
$ export PATH=/usr/local/cuda-12.0/bin${PATH:+:${PATH}}
$ export LD_LIBRARY_PATH=/usr/local/cuda-12.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Source the ~/.bashrc
file to apply the changes:
$ source ~/.bashrc
Step 5: Verify the CUDA Installation
To verify the installation, compile and run the sample programs provided with the CUDA toolkit:
-
Navigate to the sample directory:
$ cd /usr/local/cuda-12.0/samples
-
Compile the samples:
$ sudo make
-
Run a sample program to ensure CUDA is working:
$ cd bin/x86_64/linux/release ./deviceQuery
.
If the installation is successful, you should see output indicating that the program has detected your GPU and displays its properties.
Conclusion
Congratulations! You have successfully installed and configured CUDA on Ubuntu 24.04 Noble Numbat. You can now harness the power of your NVIDIA GPU for parallel computing tasks. For more detailed information and advanced usage, refer to the NVIDIA CUDA Toolkit documentation.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.