Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Install NVIDIA GPU driver on Linux (Ubuntu/Debian)
Batkhuu
Batkhuu

Posted on

     

Install NVIDIA GPU driver on Linux (Ubuntu/Debian)

Official pages


Install NVIDIA GPU driver

Disable automatic updates on Ubuntu/Debian

# 1. Disable auto-update and auto-upgrade:echo'APT::Periodic::Update-Package-Lists "0";' |sudo tee /etc/apt/apt.conf.d/20auto-upgradesecho'APT::Periodic::Unattended-Upgrade "0";' |sudo tee-a /etc/apt/apt.conf.d/20auto-upgrades
Enter fullscreen modeExit fullscreen mode

Disable open-source nouveau driver

# 2. Write blacklist options for the nouveau driver (disable):echo"blacklist nouveau" |sudo tee-a /etc/modprobe.d/blacklist-nouveau.confecho"options nouveau modeset=0" |sudo tee-a /etc/modprobe.d/blacklist-nouveau.conf# 3. Update kernel initramfs for blacklist (modprobe.d) options:sudoupdate-initramfs-u
Enter fullscreen modeExit fullscreen mode

Install essential packages

# 4. Clean apt package manager lists and caches:sudo rm-vrf /var/lib/apt/lists/* /var/cache/apt/archives/* /tmp/*sudoapt-get clean-y# 5. Updating, indexing, and caching apt package manager app lists:sudoapt-get update--fix-missing-o Acquire::CompressionTypes::Order::=gz# 6. Upgrade and reinstall OS base packages:sudoapt-get upgrade-y# 7. Remove old or unnecessary leftover packages:sudoapt-get autoremove-y# 8. IMPORTANT! Install dkms and base packages:sudoapt-getinstall-y build-essential pkg-config libglvnd-dev mesa-utils wget dkms
Enter fullscreen modeExit fullscreen mode

Download the appropriate Linux driver for the current NVIDIA GPU model

  • Search and download the latest verified stable NVIDIA GPU driver (NVIDIA-Linux-x86_64-***.run) installer file from this link:https://www.nvidia.com/Download/Find.aspx?lang=en-us
  • IMPORTANT!Download and use the .RUN file! It can install the NVIDIA driver with theDKMS module, which is really important!
  • IMPORTANT!Don't download or use the .DEB file! It willBREAK the kernel eventually, especially when the kernel header/version/module is upgraded, which is soFRUSTRATING! Therefore, sometimes conflict with other applicationdependencies (dependency hell)...
  • If you're using a command-line interface, just copy the download link and use wget to download. For example:
mkdir-v ~/Downloadscd ~/Downloads# 9. (Skip this, if you've already downloaded) Download appropriate Linux driver for current NVIDIA GPU modelwget https://us.download.nvidia.com/[GPU_MODEL_TYPE_URL]/NVIDIA-Linux-x86_64-[DRIVER_VERSION].run# For example:wget https://us.download.nvidia.com/XFree86/Linux-x86_64/510.54/NVIDIA-Linux-x86_64-510.54.run
Enter fullscreen modeExit fullscreen mode

Preparation steps before installing NVIDIA GPU driver

[IMPORTANT] Change GUI environment to console environment

  • Skip this step to 11, if you're not using a GUI environment and already using a console environment or SSH
  • TIP: From here you're going to enter the console environment, so you need to write down these below commands on some text file to read from command-line or note on somewhere!
  • You can change the GUI environment to a virtual console environment by pressing these keyboard buttons:Ctrl + Alt + F1/F3
  • Or by entering the Linux command:
# 10. IMPORTANT! Entering into virtual console environment:sudochvt 1# Or:sudochvt 3
Enter fullscreen modeExit fullscreen mode
  • Enter username and password to log in to a console environment

Stop GUI processes to prepare the installation of the NVIDIA GPU driver

# 11. Stop GUI service (lightdm/gdm/gdm3/kdm/slim/etc..):sudoservice lightdm stop# Or:sudoservice gdm stop# Or:sudoservice gdm3 stop# 12. Initialize and refresh console environment without X11 (GUI) processes:sudoinit 3# Change directory to NVIDIA-Linux-x86_64-***.run driver downloaded directory. For example:cd ~/Downloads# 13. Change permission of NVIDIA-Linux-x86_64-***.run driver installer file to executable:chmod +x ./NVIDIA-Linux-x86_64-[DRIVER_VERSION].run# For example:chmod +x ./NVIDIA-Linux-x86_64-510.54.run
Enter fullscreen modeExit fullscreen mode

Install NVIDIA driver.run file

  • IMPORTANT! (--dkms) Register Nvidia driver to the DKMS for future kernel upgrade.
  • IMPORTANT! (--no-x-check) Disable the X11 config checker to prevent triggering X11 (GUI) processes while installing the driver.
  • IMPORTANT! (--no-cc-version-check) Disable the C/C++ version checker to prevent install error occurs when the DKMS C/C++ version is not matching with the current installed C/C++ version!
# 14. IMPORTANT! Install nvidia driver with appropriate arguments:sudo ./NVIDIA-Linux-x86_64-[DRIVER_VERSION].run--no-x-check--no-cc-version-check--dkms# For example:sudo ./NVIDIA-Linux-x86_64-510.54.run--no-x-check--no-cc-version-check--dkms
Enter fullscreen modeExit fullscreen mode
  • Select 'Continue installation' on the warning message.
  • IMPORTANT! Select 'Yes' for the register of the DKMS kernel module.
  • Select 'No' for 32-bit compatibility installation OR select 'OK' when a 32-bit compatibility error appears.
  • IMPORTANT! Select 'No' when it asks to automatically update your X configuration file.
# 15. Remove downloaded file:rm-vf ./NVIDIA-Linux-x86_64-[DRIVER_VERSION].run# For example:rm-vf ./NVIDIA-Linux-x86_64-510.54.run# 16. Reboot system:sudoshutdown-r now# 17. Check nvidia driver is installed:nvidia-smi
Enter fullscreen modeExit fullscreen mode

Post-installation

[Only for ML/DL server] Setup nvidia-persistence mode daemon

Not recommended: GPU that is used by X11/Wayland processes (for GUI rendering).

# Install git to clone:sudoapt-getinstall-y ssh git# Download nvidia-persistenced source code from github:git clone https://github.com/NVIDIA/nvidia-persistenced.git# Install nvidia-persistenced service daemon:cdnvidia-persistenced/initsudo ./install.sh# Remove downloaded files:cd ../..&&rm-rf nvidia-persistenced# Check nvidia-persistence mode is ON:nvidia-smi# Or check nvidia-persistenced.service is running:systemctl status nvidia-persistenced.service
Enter fullscreen modeExit fullscreen mode

👍 ✨

INSTALLATION COMPLETE


[OPTIONAL] Install the NVIDIA GPU monitoring tool

🌟📡 nvitop

# Install python3 and pip3 packages:sudoapt-getinstall-y python3 python3-pip# Install nvitop into system python3 packages:sudopip3installnvitop# Check nvitop:nvitop-m full
Enter fullscreen modeExit fullscreen mode

📊 nvtop

# Install cmake, ncurses and git:sudoapt-getinstall-y cmake libncurses5-dev libncursesw5-dev# Download nvtop source code from github:git clone https://github.com/Syllo/nvtop.gitmkdir-vp nvtop/build&&cdnvtop/buildcmake ..# If it errors with "Could NOT find NVML (missing: NVML_INCLUDE_DIRS)"# try the following command instead, otherwise skip to the build with make:#cmake .. -DNVML_RETRIEVE_HEADER_ONLINE=Truemakesudomakeinstall# Remove downloaded files:cd ../..&&rm-rf nvtop# Check nvtop:nvtop
Enter fullscreen modeExit fullscreen mode

Re-install or upgrade the NVIDIA driver to the latest version

Remove DKMS NVIDIA modules

Skip this step, if you didn't install the NVIDIA driver with DKMS.

# Check current dkms nvidia modules, versions, and kernels:# [TIP]: Use module versions to remove.dkms status |grepnvidia# Remove old dkms nvidia module/version:sudodkms remove nvidia/[DRIVER_VERSION]--all# For example:sudodkms remove nvidia/510.54--all
Enter fullscreen modeExit fullscreen mode

Disable the nvidia-persistenced service daemon

Skip this step, if you didn't setup the nvidia-persistenced daemon.

# Stop and disable nvidia-persistenced service daemon:sudosystemctl stop nvidia-persistenced.servicesudosystemctl disable nvidia-persistenced.service
Enter fullscreen modeExit fullscreen mode

Uninstall all nvidia-* packages

sudoapt-get remove--purge'^nvidia-.*'# Or:sudonvidia-uninstall# Reboot system:sudoshutdown-r now
Enter fullscreen modeExit fullscreen mode

Install the latest NVIDIA driver version

Install NVIDIA driver again (start from the beginning):#install-nvidia-gpu-driver

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More fromBatkhuu

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp