This script automates the installation process of CUDA on Ubuntu. It supports multiple Ubuntu versions. Follow these steps to install CUDA on your system.
Run the script with the desired Ubuntu version as an argument:
bash install_cuda.sh <ubuntu_version>
-
Download the CUDA pin for Ubuntu 22.04:
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
-
Move the CUDA pin to the appropriate directory:
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
-
Download the CUDA repository package:
wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb
-
Install the CUDA repository package:
sudo dpkg -i cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb
-
Copy the CUDA keyring to the system keyrings directory:
sudo cp /var/cuda-repo-ubuntu2204-12-0-local/cuda-*-keyring.gpg /usr/share/keyrings/
-
Update the package list:
sudo apt-get update
-
Install CUDA:
sudo apt-get -y install cuda
To verify the installation, you can check the CUDA version:
nvidia-smi -l 1