Advertisement
fant0men

How to install the official NVIDIA drivers in Linux

Oct 16th, 2019
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. Install the official driver. Go and download the official NVIDIA Linux driver for your graphics card, put the file in the root of your home directory (~/ or /home/user).
  2.  
  3. Download the driver, and make sure it's for your card:
  4.  
  5. https://www.nvidia.com/Download/index.aspx?lang=en-us
  6.  
  7. Shut down all running applications on your desktop, log out.
  8.  
  9. Switch to a background terminal (Ctrl + Alt + F#). There is a terminal for each of the F keys, so you can pick any number, for example F3. The desktop is usually on F1, F5 or F7.
  10.  
  11. First, login as root (admin):
  12.  
  13. sudo su
  14.  
  15. If you're running a flavor of Ubuntu or Mint, now install a package called "build-essential" (you need it to compile the graphics driver's kernel module). If you're running Fedora, you need a group package called "@development-tools":
  16.  
  17. apt-get install build-essential (for Ubuntu)
  18. dnf install @development-tools (for Fedora)
  19.  
  20. Next do this, to make sure the NVIDIA run file is executable:
  21.  
  22. chmod +x /home/user/NVIDIA-Linux-x86_64-*.run
  23.  
  24. Before you install the NVIDIA drivers, you need to make sure your other NVIDIA drivers (Nouveau and the like) are uninstalled from the package manager.
  25.  
  26. For example:
  27.  
  28. apt-get remove xserver-xorg-video-nouveau (for Ubuntu)
  29. dnf remove xorg-x11-drv-nouveau (for Fedora)
  30.  
  31. Now we need to rewrite the kernel image, without the Nouveau kernel module (since we just removed it from the system):
  32.  
  33. dracut --force
  34.  
  35. Now reboot (to load the new kernel image):
  36.  
  37. reboot
  38.  
  39. Go back to a TTY (as before). When in the background terminal, shut down your display manager (the process / service that starts the desktop, X or Wayland). If for example you run Linux Mint with the Cinnamon desktop environment, you're probably using the LightDM display manager. If you're running Fedora, you're likely using the GDM display manager.
  40.  
  41. sudo su
  42. service gdm stop
  43.  
  44. Install the NVIDIA drivers:
  45.  
  46. /home/user/NVIDIA-Linux-x86_64-*.run
  47.  
  48. Follow the instructions on screen. It's not difficult. The kernel module will be compiled. The installer will ask if you want 32-bit libraries installed, say yes. Then the installer will probably ask you if it can change the X config. Just say yes to that. And then you're done.
  49.  
  50. Then do:
  51.  
  52. service gdm start
  53.  
  54. And you're done. Now you have the latest official NVIDIA drivers, and they should work better than whatever you had before.
  55.  
  56. You can check if you have the NVIDIA drivers loaded by running:
  57. glxinfo > glxinfo_output.txt
  58.  
  59. And then reading that file in a text editor, searching for "nvidia".
  60.  
  61. (The reason you want to use the official driver is that it's almost always newer than the one available in your distribution's repositories, and it's faster than the open source drivers.)
  62.  
  63. The official driver is compiled against the currently installed kernel. Each time there's a kernel update (which is pretty often), the driver will have to be reinstalled. Therefore, it's a good idea keeping the kernel packages from being updated. You can do so on Fedora:
  64.  
  65. sudo echo "excludepkgs=kernel*" >> /etc/dnf/dnf.conf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement