CentOS 7.x Install nvidia drivers and cuda library
From Notes_Wiki
Home > CentOS > CentOS 7.x > System Administration > Package management > CentOS 7.x Install nvidia drivers and cuda library
To install Nvidia drivers and Cuda library on CentOS 7.x use:
- Do full installation of CentOS7
- Disable Selinux by editing '/etc/selinux/config' and using:
- SELINUX=disabled
- Also do
- setenforce 0
- Disable firewalld
- systemctl stop firewalld
- systemctl disable firewalld
- Install EPEL & DKMS
- yum install epel-release -y
- yum install kernel-devel epel-release dkms
- Full update
- yum update -y
- In CentOS7, Default there is no xorg.conf file. Take backup if you found.
- cd /etc/X11/
- cp xorg.conf original-xorg-conf
- In CentOS7, NVIDIA card uses NOUVEAU open source driver. Check with below command
- lshw -numeric -C display
- Diable this open source driver at kernel level by editing '/etc/default/grub' with:
- GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet nouveau.modeset=0"
- Apply new GRUB configuration using
- grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
- On non-EFI systems above command could be:
- grub2-mkconfig -o /boot/grub2/grub.cfg
- Reboot the and make sure GUI works properly
- shutdown -r now
- Verify NVIDIA card not using nouveau driver
- lshw -numeric -C display
- Download the gpu card drivers repo file for compatible OS from https://www.nvidia.com/Download/index.aspx?lang=en-us
- If you dont want the latest cuda (12.2 at time of this writing) then we can go for download page for specific version of cuda and use that. For example for cuda-10.2 link is https://developer.nvidia.com/cuda-10.0-download-archive
- Install the downloaded repo
- yum -y localinstall nvidia-driver-local-repo-rhel7-515.48.07-1.0-1.x86_64.rpm
- Change to run level 3
- systemctl isolate multi-user.target
- Install the cuda drivers
- yum install nvidia-kmod cuda-drivers
- If any nvidia.conf files in /etc/X11/ or /etc/X11/xorg.conf.d/, comment all the lines.
- Remove any xorg.conf file. No need to create any xorg.conf file with busid
- Reboot the gpu node
- shutdown -r now
- Check the gpu card status using:
- nvidia-smi
- If you able to execute the above command and able to see the nvidia card details, then drivers were installed properly.
- Download correct version of CUDA repo rpm file from https://developer.nvidia.com/cuda-downloads
- Install cuda using:
- yum localinstall cuda-repo-rhel7-10-0-local-10.0.130-410.48-1.0-1.x86_64.rpm
- yum install cuda
- In case of gpg errors we can use 'yum -y --nogpgcheck install cuda' as cuda-sanitizer package is perhaps not signed properly via the key.
- Check cuda version using:
- ls /usr/local/cuda*
- Export system path to Nvidia CUDA binary executables by executing below in current shell:
- export PATH=/usr/local/cuda-<ver>/bin${PATH:+:${PATH}}
- export LD_LIBRARY_PATH=/usr/local/cuda-<ver>/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
- Note that we should use "module load", "module available" etc. command to set appropriate environment for cuda-11.2 based on the requirement of the program being compiled / executed.
- Read updated bashrc file in current shell using:
- source /etc/bashrc
- ldconfig
- Check cuda version details with the below command
- nvcc --version
Home > CentOS > CentOS 7.x > System Administration > Package management > CentOS 7.x Install nvidia drivers and cuda library