1. Download and Install CUDA Keyring:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
2. Update system and Install CUDA Toolkit:
sudo apt-get update -y
sudo apt-get install cuda-toolkit -y
3. Reboot:
sudo sync; sudo /sbin/shutdown -r now
4. Configure Environment Variables:
Add the following lines to the end of your ~/.bashrc file to set the environment variables:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.5/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
then:
source ~/.bashrc
5. Verify the Installation
nvcc -V
You should see an output similar to:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Jun__6_02:18:23_PDT_2024
Cuda compilation tools, release 12.5, V12.5.82
Build cuda_12.5.r12.5/compiler.34385749_0
Additional Notes:
Persistence Daemon: If you want to enable the NVIDIA Persistence Daemon for better GPU management, you can start it as root:
/usr/bin/nvidia-persistenced --verbose
Deploy GPU-accelerated applications in containers:
sudo apt-get install -y nvidia-docker2
Then test:
sudo docker run --rm --gpus all nvidia/cuda:12.5.0-base-ubuntu22.04 nvidia-smi
Install nvidia driver:
sudo apt-get install nvidia-driver-555
Then, test:
nvidia-smi
reference:
Installing the NVIDIA Container Toolkit
NVIDIA CUDA Installation Guide for Linux