当前位置:   article > 正文

Ubuntu安装NVIDIA显卡驱动_ubantu安装配置550驱动

ubantu安装配置550驱动

在Ubuntu上查看电脑显卡型号以及下载对应的驱动,可以按照以下步骤进行:

1: 查看显卡型号:

打开终端(Terminal)。
输入命令 lspci | grep -i vga 或者 lspci | grep -i nvidia(如果是NVIDIA显卡),然后按Enter键。这将列出与显卡相关的信息。
在输出信息中,查找显卡型号。通常,显卡型号会显示在类似于“VGA compatible controller”或“NVIDIA Corporation”的行中。

wcx@wcx-Ubuntu:~/Desktop$  lspci | grep -i vga 
01:00.0 VGA compatible controller: NVIDIA Corporation TU116 [GeForce GTX 1660 SUPER] (rev a1)
wcx@wcx-Ubuntu:~/Desktop$  lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation TU116 [GeForce GTX 1660 SUPER] (rev a1)
01:00.1 Audio device: NVIDIA Corporation TU116 High Definition Audio Controller (rev a1)
01:00.2 USB controller: NVIDIA Corporation TU116 USB 3.1 Host Controller (rev a1)
01:00.3 Serial bus controller [0c80]: NVIDIA Corporation TU116 [GeForce GTX 1650 SUPER] (rev a1)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

2:下载对应驱动:

访问NVIDIA官方网站 https://www.nvidia.com/Download/index.aspx?lang=en-us
在网站上选择适当的显卡型号和操作系统(Ubuntu及其版本)。
下载与你的显卡型号和Ubuntu版本相匹配的驱动程序。通常,这会是一个.run文件。
在这里插入图片描述
在这里插入图片描述

3. 更新系统和安装依赖

打开终端,输入以下命令:

sudo apt update  
sudo apt upgrade  
sudo apt install gcc g++ make
  • 1
  • 2
  • 3

4. 禁用Nouveau

Nouveau是一个开源的显卡驱动,与NVIDIA的官方驱动冲突。在安装NVIDIA驱动之前,需要禁用它

编辑黑名单文件:

sudo nano /etc/modprobe.d/blacklist.conf
  • 1

在文件末尾添加以下行:

blacklist nouveau  
options nouveau modeset=0
  • 1
  • 2

保存并关闭文件。然后更新initramfs并重启:

sudo update-initramfs -u  
sudo reboot

  • 1
  • 2
  • 3

5: 停止图形界面:

在重启后,界面为黑色,进入命令行模式(通常可以按Ctrl+Alt+F2或其他F键)。登录到你的用户账户

在这里插入图片描述

6: 安装NVIDIA驱动:

首先,你可能需要停止lightdm或gdm服务(取决于你使用的显示管理器)
wenchenxing@wenchenxing-virtual-machine:~/Downloads$ sudo service lightdm stop
wenchenxing@wenchenxing-virtual-machine:~/Downloads$ ls
NVIDIA-Linux-x86_64-535.86.05.run
wenchenxing@wenchenxing-virtual-machine:~/Downloads$ chmod a+x NVIDIA-Linux-x86_64-550.54.16.run
wenchenxing@wenchenxing-virtual-machine:~/Downloads$ sudo ./NVIDIA-Linux-x86_64-550.54.16.run
Verifying archive integrity… OK

在这里插入图片描述

一直 enter

7:重启并验证

安装完成后,重启你的计算机:
sudo reboot
重启后,你可以通过运行以下命令来验证NVIDIA驱动是否正确安装:

nvidia-smi
如果一切正常,这个命令应该会显示关于你的NVIDIA显卡的信息。

wcx@wcx-Ubuntu:~/Desktop$ nvidia-smi
Sun Feb 25 16:00:23 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.54.14              Driver Version: 550.54.14      CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce GTX 1660 ...    Off |   00000000:01:00.0  On |                  N/A |
| 30%   42C    P8              7W /  125W |     211MiB /   6144MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      1097      G   /usr/lib/xorg/Xorg                             35MiB |
|    0   N/A  N/A      1776      G   /usr/lib/xorg/Xorg                             47MiB |
|    0   N/A  N/A      1908      G   /usr/bin/gnome-shell                          118MiB |
+-----------------------------------------------------------------------------------------+

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

报错:NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

wcx@wcx-Ubuntu:~/Desktop$ sudo nvidia-smi
[sudo] password for wcx: 
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
  • 1
  • 2
  • 3

原因: Ubuntu更新后导致内核不兼容导致

查看Ubuntu更新
wcx@wcx-Ubuntu:~/Desktop$ uname -a
Linux wcx-Ubuntu 5.15.0-100-generic #110~20.04.1-Ubuntu SMP Tue Feb 13 14:25:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

检查cuda是否存在

wcx@wcx-Ubuntu:~/Desktop$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
  • 1
  • 2
  • 3
  • 4
  • 5

查看已安装驱动版本

wcx@wcx-Ubuntu:~/Desktop$ ls /usr/src/ | grep nvidia
nvidia-550.54.14
  • 1
  • 2

安装dkms 可以做到内核变更后自动编译模块,适配新内核

wcx@wcx-Ubuntu:~/Desktop$ sudo apt install dkms
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  dctrl-tools
Suggested packages:
  debtags menu
The following NEW packages will be installed:
  dctrl-tools dkms
0 upgraded, 2 newly installed, 0 to remove and 11 not upgraded.
Need to get 128 kB of archives.
After this operation, 599 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 dctrl-tools amd64 2.24-3 [61.5 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 dkms all 2.8.1-5ubuntu2 [66.8 kB]
Fetched 128 kB in 1s (105 kB/s)
Selecting previously unselected package dctrl-tools.
(Reading database ... 213981 files and directories currently installed.)
Preparing to unpack .../dctrl-tools_2.24-3_amd64.deb ...
Unpacking dctrl-tools (2.24-3) ...
Selecting previously unselected package dkms.
Preparing to unpack .../dkms_2.8.1-5ubuntu2_all.deb ...
Unpacking dkms (2.8.1-5ubuntu2) ...
Setting up dctrl-tools (2.24-3) ...
Setting up dkms (2.8.1-5ubuntu2) ...
Processing triggers for man-db (2.9.1-1) ...

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

使用dkms重新编译当前驱动适配当前内核

wcx@wcx-Ubuntu:~/Desktop$ sudo dkms install -m nvidia -v 550.54.14

Creating symlink /var/lib/dkms/nvidia/550.54.14/source ->
                 /usr/src/nvidia-550.54.14

DKMS: add completed.

Kernel preparation unnecessary for this kernel.  Skipping...

Building module:
cleaning build area...
'make' -j16 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=5.15.0-100-generic modules..........
Signing module:
Generating a new Secure Boot signing key:
Can't load /var/lib/shim-signed/mok/.rnd into RNG
140081268356416:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:98:Filename=/var/lib/shim-signed/mok/.rnd
Generating a RSA private key
.................................+++++
......................................+++++
writing new private key to '/var/lib/shim-signed/mok/MOK.priv'
-----
 - /var/lib/dkms/nvidia/550.54.14/5.15.0-100-generic/x86_64/module/nvidia.ko
 - /var/lib/dkms/nvidia/550.54.14/5.15.0-100-generic/x86_64/module/nvidia-modeset.ko
 - /var/lib/dkms/nvidia/550.54.14/5.15.0-100-generic/x86_64/module/nvidia-peermem.ko
 - /var/lib/dkms/nvidia/550.54.14/5.15.0-100-generic/x86_64/module/nvidia-drm.ko
 - /var/lib/dkms/nvidia/550.54.14/5.15.0-100-generic/x86_64/module/nvidia-uvm.ko
Secure Boot not enabled on this system.
cleaning build area...

DKMS: build completed.

nvidia.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.15.0-100-generic/updates/dkms/

nvidia-uvm.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.15.0-100-generic/updates/dkms/

nvidia-modeset.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.15.0-100-generic/updates/dkms/

nvidia-drm.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.15.0-100-generic/updates/dkms/

nvidia-peermem.ko:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/5.15.0-100-generic/updates/dkms/

depmod..........

DKMS: install completed.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69

nvidia-smi

wcx@wcx-Ubuntu:~/Desktop$ nvidia-smi
Fri Mar 15 18:23:27 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.54.14              Driver Version: 550.54.14      CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce GTX 1660 ...    Off |   00000000:01:00.0 Off |                  N/A |
| 21%   50C    P0             31W /  125W |       0MiB /   6144MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/866672
推荐阅读
相关标签
  

闽ICP备14008679号