Install CUDA in ubuntu system

This is a simple guide to install CUDA on an Ubuntu system.

Check GPU model

First, check your GPU model by running the following command in the terminal:

lspci | grep -i nvidia

Download CUDA Toolkit

Go to the NVIDIA CUDA Downloads page

Select:

Installation Instructions will be shown below the selection. Follow the instructions to download the CUDA toolkit with wget.

Install CUDA Toolkit

Open a terminal and navigate to the directory where you downloaded the CUDA runfile. Make the runfile executable and run it:


chmod +x your_cuda_installation.run
sudo ./your_cuda_installation.run

Follow the prompts to complete the installation. You may need to accept the EULA and choose installation options.

During the installation, you may be prompted to install the NVIDIA driver. Skip this by unchecking the box. Because it will install a new driver on your system that might cause your pc to stuck on reboot.


CUDA Installer
- [ ] Driver
     [ ] 550.54.14
+ [X] CUDA Toolkit 12.4
  [ ] CUDA Demo Suite 12.4
  [ ] CUDA Documentation 12.4
- [ ] Kernel Objects
     [ ] nvidia-fs
  Options
  Install

Set Environment Variables

Add the following lines to your ~/.bashrc file to set the environment variables for CUDA:


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

Then, source the ~/.bashrc file to apply the changes:

source ~/.bashrc

Verify Installation

To verify that CUDA is installed correctly, you can check the version of nvcc:

nvcc --version

You can also check the CUDA version using nvidia-smi:

nvidia-smi

The versions shown by nvcc and nvidia-smi may differ, which is normal. nvcc shows the CUDA toolkit version, while nvidia-smi shows the driver version.

That's it! You have successfully installed CUDA on your Ubuntu system.

-->