重新安装NVIDIA显卡驱动

Posted eugene0

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了重新安装NVIDIA显卡驱动相关的知识,希望对你有一定的参考价值。

1 卸载旧的显卡驱动

sudo apt-get remove nvidia*

查看linux系统中的CUDA版本:

cat /usr/local/cuda/version.txt
CUDA Version 10.1.105

2 下载显卡驱动

首先查看显卡型号:

root@iZbp1bdnlickm9umikq90uZ:~# lshw -numeric -C display
  *-display:0             
       description: VGA compatible controller
       product: GD 5446 [1013:B8]
       vendor: Cirrus Logic [1013]
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 00
       width: 32 bits
       clock: 33MHz
       capabilities: vga_controller rom
       configuration: driver=cirrus latency=0
       resources: irq:0 memory:fa000000-fbffffff memory:fe050000-fe050fff memory:fe040000-fe04ffff
  *-display:1 UNCLAIMED
       description: 3D controller
       product: GP100GL [Tesla P100 PCIe 16GB] [10DE:15F8]
       vendor: NVIDIA Corporation [10DE]
       physical id: 9
       bus info: pci@0000:00:09.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress cap_list
       configuration: latency=0
       resources: iomemory:80-7f iomemory:c0-bf memory:fd000000-fdffffff memory:800000000-bffffffff memory:c00000000-c01ffffff

可以看到我的显卡是P100,根据显卡、CUDA版本下载适合的驱动,这里有一张参照表:

技术图片

下载驱动:NVIDIA-Linux-x86_64-430.50.run

3 安装相关依赖包

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

4 有图形界面需禁用x-window服务

sudo service lightdm stop

5 禁用nouveau

禁用nouveau后才能成功安装NVIDIA显卡驱动

sudo vi /etc/modprobe.d/blacklist.conf
#添加以下内容
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

执行命令

echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf build the new kernel by:

更新并重启

sudo update-initramfs -u
reboot

6 安装

sudo chmod a+x NVIDIA-Linux-x86_64-430.50.run*
sudo sh NVIDIA-Linux-x86_64-430.50.run* --no-opengl-files --no-x-check --no-nouveau-check
  • no-opengl-files 只安装驱动文件,不安装OpenGL文件。这个参数最重要
  • no-x-check 安装驱动时不检查X服务
  • no-nouveau-check 安装驱动时不检查nouveau

技术图片

7 查看是否安装成功

nvidia-smi
Wed Sep 25 16:38:54 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.50       Driver Version: 430.50       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla P100-PCIE...  Off  | 00000000:00:09.0 Off |                    0 |
| N/A   27C    P0    26W / 250W |      0MiB / 16280MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:17_PST_2019
Cuda compilation tools, release 10.1, V10.1.105

查看NVIDIA驱动版本信息:

cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  430.50  Thu Sep  5 22:36:31 CDT 2019
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)

以上是关于重新安装NVIDIA显卡驱动的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 DKMS 将 NVIDIA .run 驱动程序重新打包到 .deb 中

Ubuntu18.04安装 NVIDIA驱动

nvidia控制面板打不开,提示程序出现问题

Ubuntu如何卸载NVIDIA驱动

Nvidia GeForce GT 730显卡驱动停止运行是啥情况?

如何安装NVIDIA GeForce GT 720M 显卡驱动