Three ways to install Nvidia drivers on ubuntu18.04 (must read)

The starting point for writing a tutorial is the same every time. What everyone writes is not comprehensive enough, which can easily lead to operational errors.

By the way, I will record the days when I worked overtime as a driver at Baidu. . .

1. Overview

Generally speaking, there are three ways to install drivers, 1> Install through runfile (more difficult); 2> Install through software updater (easy); 3> Install through ppa source (easy). Novices can do the latter two. The first one is prone to black screens, loop logins, installation abnormalities, and switching between text mode and graphics mode, which is difficult to control.

No matter which method, first disable nouveau. It is something created by the open source community. I originally thought of wrestling with nvidia. Unexpectedly, everyone took the first step and disabled it. Otherwise, it may conflict with the nvidia driver (I did it once before). If you can't disable it, it's annoying).

Terminal input:

sudo gedit /etc/modprobe.d/blacklist-nouveau.conf
或者
sudo vi /etc/modprobe.d/blacklist-nouveau.conf

Add at the end of the file:

blacklist nouveau

options nouveau modeset=0

After writing and saving, the update enables disabling nouveau to take effect:

sudo update-initramfs -u

Restart the system (be sure to restart), and then verify

lsmod | grep nouveau

No information is displayed, indicating that nouveau has been disabled. Next, you can install the nvidia driver.

Not much to say, let's start with soft persimmons.

ps:

This is something that others have mentioned repeatedly. I haven't done this, but I can, so you can figure it out for yourself.

! ! ! ! Before installing the graphics card driver, restart the computer and enter the BIOS to turn off UEFI secure boot (disable). This is very important! ! ! !
! ! ! ! Before installing the graphics card driver, restart the computer and enter the BIOS to turn off UEFI secure boot (disable). This is very important! ! ! !
! ! ! ! Before installing the graphics card driver, restart the computer and enter the BIOS to turn off UEFI secure boot (disable). This is very important! ! !

2. Install through software update

1. First close nouveau

2. Add the ppa source, the software update method also needs to add the source! ! !

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

3. Open Software Update, Additional Programs, click on one of the drivers to install it, and after installation is complete, restart the computer.

ps: Software updates can be found in the application bar in the lower left corner of Ubuntu, enter update and then open

3. Install via PPA source

Steps 1 and 2 are equivalent to the software update method

3. Check the driver

ubuntu-drivers devices

The content is as follows:

== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
vendor   : NVIDIA Corporation
modalias : pci:v000010DEd00001F11sv000017AAsd00003FFDbc03sc00i00
driver   : xserver-xorg-video-nouveau - distro free builtin
driver   : nvidia-418 - third-party free
driver   : nvidia-430 - third-party free

Note: There is a little guy with a mark on the far right, saying recommended, which is recommended by the system. The autoinstall below will automatically install this. Generally, this is enough, but there are special circumstances.

4. Installation

sudo ubuntu-drivers autoinstall
或者
sudo apt-get install nvidia-430

5. Restart

sudo reboot

ps: Since I work for Baidu, I can be scientific. If your Internet speed is slow, please click here.

Two ways to solve the slow download speed of apt-get_Might_Guy.'s blog-CSDN blog_apt is slow 1. Replace apt-get with the domestic mirror source to view the source used: sudo gedit /etc/apt/sources.list will be the default The source was changed to the domestic Alibaba mirror source (cn.archive.ubuntu.com). Now cn.archive.ubuntu.com points to Alibaba Cloud's open source mirror station mirrors.aliyun.com, and the download speed is faster. Rename the original source as a backup: sudo mv /etc/apt/s... https://blog.csdn.net/weixin_46474546/article/details/104708220

So far, the driver should be safe! I hope you don’t use the following. This fault tolerance rate is not high. If you don’t back up important data first, you may have to restart the system.

4. Install the driver through runfile

1. Disable nouveau

2. Download driver

Go to nvidia driver official website

Official Advanced Driver Search | NVIDIA Advanced driver search for GeForce, TITAN, NVIDIA RTX, data center, GRID and other NVIDIA products. icon-default.png?t=M276https://www.nvidia.cn/download/find.aspx?lang=cnEnter the type of your graphics card and find the appropriate driver

The version I downloaded: NVIDIA-Linux-x86_64-396.18.run (note that different versions have different final installation and execution options)

Copy the downloaded run file to the home directory.

3. Switch between text mode and graphics mode

PS: Press ctrl+alt+f1 under ubuntu to enter the command line interface (the computer screen is black), enter your account and password to log in (remember your account and password), and return to the graphical mode through Ctrl + Alt + F7

PS: Note: Different computer keys are not fixed, but they are all ctrl+arl+F1~F12. Try pressing them all. The first time you enter, enter your account and password and then look for the return button to avoid stress.

The fun begins:

Enter (required) in the command line interface:

     sudo service lightdm stop      //这个是关闭图形界面,不执行会出错。

Then uninstall the original driver (if you have installed other drivers, you must/must clean them up, otherwise you will log in in a loop and crash):

sudo apt-get remove nvidia-*  (若安装过其他版本或其他方式安装过驱动执行此项)
sudo apt-get autoremove

4. Install run file

Grant execution permissions to the driver run file (the command line model cannot be TAB completed, enter it by yourself, be careful):

     sudo chmod  a+x NVIDIA-Linux-x86_64-396.18.run

Install:

sudo ./NVIDIA-Linux-x86_64-396.18.run -no-x-check -no-nouveau-check -no-opengl-files //只有禁用opengl这样安装才不会出现循环登陆的问题

-no-x-check: Turn off the X service when installing the driver

-no-nouveau-check: Disable nouveau when installing the driver

-no-opengl-files: Only install driver files, not OpenGL files

See here for the important options (questions may not necessarily be asked in order):

1. There appears to already be a driver installed on your system (version:      
  390.42).  As part of installing this driver (version: 390.42), the existing  
  driver will be uninstalled.  Are you sure you want to continue? 
  Continue installation      Abort installation 
(选择 Coninue,如果是重装的话)
2. The distribution-provided pre-install script failed!  Are you sure you want
  to continue?                                                                 
 Continue installation      Abort installation       
(选择 Cotinue)
3. Would you like to register the kernel module sources with DKMS? This will    
  allow DKMS to automatically build a new module, if you install a different   
  kernel later.
Yes                       No  
(这里选 No)
4. Install NVIDIA's 32-bit compatibility libraries?
    Yes                       No  
(这里选 No)
5. Installation of the kernel module for the NVIDIA Accelerated Graphics Driver
  for Linux-x86_64 (version 390.42) is now complete.                           
  OK
6.Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up. 
    Yes                       No  
(这里选 Yes)

5. Start GUI and reboot

     sudo service lightdm start

After completing the above command, you will automatically return to the login interface, and then just restart.

sudo reboot

6. Mount the Nvidia driver (I can do it without mounting it):

modprobe nvidia

Check if the driver is installed successfully:

nvidia-smi

 

reference:

Ubuntu16.04 uses PPA to install NVIDIA graphics card driver easily and quickly_Might_Guy.'s blog-CSDN blog

Record of installing Nvidia driver in Ubuntu 18.04 (.run)_midori's blog-CSDN blog Ubuntu18.04 Installation of Nvidia graphics driver record_Que Ranzhisu's blog-CSDN blog Installing nvidia graphics driver in ubuntu16.04 system run method_xunan003's blog-CSDN Blog_ubuntu Install the graphics driver Ubuntu18.04 Install the Nvidia graphics driver record_Que Ranzhisu's blog-CSDN blog record Ubuntu 18.04 (.run) method to install the Nvidia driver_midori's blog-CSDN blog

Guess you like

Origin blog.csdn.net/qq_37424778/article/details/123380322