做深度学习相关的学习或工作时,安装显卡的驱动是第一件要做的事,本文以nvidia Geforce 1070Ti
显卡为例,分享2种由易到难(其实也不难)的安装方法,供大家参考。
这种方法对大部分人来说,是最容易也是最推荐的方法。在终端输入sudo ubuntu-drivers devices
(base) xugaoxiang@1070Ti:~$ sudo ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0 ==
modalias : pci:v000010DEd00001B82sv00001458sd00003794bc03sc00i00
vendor : NVIDIA Corporation
model : GP104 [GeForce GTX 1070 Ti]
driver : nvidia-driver-390 - distro non-free
driver : nvidia-driver-435 - distro non-free
driver : nvidia-driver-450 - distro non-free
driver : nvidia-driver-450-server - distro non-free recommended
driver : nvidia-driver-418-server - distro non-free
driver : nvidia-driver-440-server - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
从上面的输出信息中可以看到当前机器中的显卡信息以及可以安装的驱动版本,其中recommended
是默认推荐的版本,执行下面命令安装推荐的版本
sudo ubuntu-drivers autoinstall
如果你想安装其他的版本,如435版本,可以使用apt
安装
sudo apt install nvidia-driver-435
安装成功后,需要重启系统生效,然后进入终端terminal
,执行nvidia-smi
进行验证
(base) xugaoxiang@1070Ti:~$ nvidia-smi
Thu Sep 24 13:20:51 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.66 Driver Version: 450.66 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| 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 GeForce GTX 107... Off | 00000000:03:00.0 On | N/A |
| 0% 54C P5 18W / 180W | 623MiB / 8116MiB | 22% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1525 G /usr/lib/xorg/Xorg 247MiB |
| 0 N/A N/A 2088 G /usr/bin/gnome-shell 206MiB |
| 0 N/A N/A 3138 G ...charm-2020.1/jbr/bin/java 7MiB |
| 0 N/A N/A 12627 G ...AAAAAAAAA= --shared-files 157MiB |
+-----------------------------------------------------------------------------+
(base) xugaoxiang@1070Ti:~$
至此,nvidia
显卡的驱动就已经安装成功了
我们到nvidia
的官方网站去下载相应的驱动安装文件,地址是 https://www.nvidia.com/download/index.aspx?lang=en-us
根据自己的操作系统、显卡型号、显示语言等实际情况选择
接下来,点击Download
就可以下载了,完成后是一个run
文件
chmod a+x NVIDIA-Linux-x86_64-450.66.run
sudo ./NVIDIA-Linux-x86_64-450.66.run
按照提示一步步安装就可以了。安装好了后,同样是重启电脑并使用nvidia-smi
来验证是否成功