CentOS 7.x Install nvidia drivers and cuda library

From Notes_Wiki
Revision as of 04:45, 30 August 2022 by Saurabh (talk | contribs)

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:

  1. Do full installation of CentOS7
  2. Disable Selinux by editing '/etc/selinux/config' and using:
    SELINUX=disabled
    Also do
    setenforce 0
  3. Disable firewalld
    systemctl stop firewalld
    systemctl disable firewalld
  4. Install EPEL & DKMS
    yum install epel-release -y
    yum install kernel-devel epel-release dkms
  5. Full update
    yum update -y
  6. In CentOS7, Default there is no xorg.conf file. Take backup if you found.
    cd /etc/X11/
    cp xorg.conf original-xorg-conf
  7. In CentOS7, NVIDIA card uses NOUVEAU open source driver. Check with below command
    lshw -numeric -C display
  8. Diable this open source driver at kernel level by editing '/etc/default/grub' with:
    GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet nouveau.modeset=0"
  9. 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
  10. Reboot the and make sure GUI works properly
    shutdown -r now
  11. Verify NVIDIA card not using nouveau driver
    lshw -numeric -C display
  12. Download the gpu card drivers repo file for compatible OS from https://www.nvidia.com/Download/index.aspx?lang=en-us
  13. Install the downloaded repo
    yum -y localinstall nvidia-driver-local-repo-rhel7-515.48.07-1.0-1.x86_64.rpm
  14. Change to run level 3
    systemctl isolate multi-user.target
  15. Install the cuda drivers
    yum install nvidia-kmod cuda-drivers
  16. If any nvidia.conf files in /etc/X11/ or /etc/X11/xorg.conf.d/, comment all the lines.
  17. Remove any xorg.conf file. No need to create any xorg.conf file with busid
  18. Reboot the gpu node
    shutdown -r now
  19. 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.
  20. Download correct version of CUDA repo rpm file from https://developer.nvidia.com/cuda-downloads
  21. 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.
  22. Check cuda version using:
    ls /usr/local/cuda*
  23. Export system path to Nvidia CUDA binary executables by editing '/etc/bashrc' with:
    export PATH=/usr/local/cuda-<ver>/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-<ver>/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  24. Read updated bashrc file in current shell using:
    source /etc/bashrc
    ldconfig
  25. 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