How to install CUDA Toolkit on Rocky Linux 9 (CUDA 12.6)

Ryan Kim
2 min readNov 16, 2024

--

Installing CUDA toolkit and how to set env path to use nvcc

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Rocky&target_version=9&target_type=rpm_local

First, you must access the Nvidia developer page to download an installer.

You can check the Rocky Linux version and CPU architecture (I chose x86 because my desktop uses Intel CPU)

Second, follow the instructions on the page. You can install the rpm file through dnf package manager.

wget https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda-repo-rhel9-12-6-local-12.6.2_560.35.03-1.x86_64.rpm
sudo rpm -i cuda-repo-rhel9-12-6-local-12.6.2_560.35.03-1.x86_64.rpm
sudo dnf clean all
sudo dnf -y install cuda-toolkit-12-6

You may not use the “nvcc” command after you install the package because your terminal does not have the CUDA path configured.

Therefore, you have to check the Cuda toolkit is installed correctly and configure the path on your terminal.

localhost:~$ nvcc --version
bash: nvcc: command not found...
localhost:~$ ls /usr/local/
bin cuda cuda-11.0 cuda-11.1 cuda-11.2 cuda-11.3 cuda-11.4 cuda-11.5 cuda-11.6 cuda-11.7 cuda-11.8 cuda-12 cuda-12.0 cuda-12.1 cuda-12.2 cuda-12.3 cuda-12.4 cuda-12.6 etc games include lib lib64 libexec sbin share src
localhost:~$ echo 'export PATH=/usr/local/cuda-12.6/bin:$PATH' >> ~/.bashrc
localhost:~$ echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
localhost:~$ source ~/.bashrc
localhost:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Sep_12_02:18:05_PDT_2024
Cuda compilation tools, release 12.6, V12.6.77
Build cuda_12.6.r12.6/compiler.34841621_0

It will be the same configuration if you set up the docker config to use it in the container environment.

--

--

Ryan Kim
Ryan Kim

No responses yet