Ubuntu 16.04 安装 NVIDIA 驱动指引_9.0

Ubuntu 16.04 安装 NVIDIA 驱动指引_9.0

原文档来自这里:https://cloud.tencent.com/document/product/560/8048
我按照步骤操作一遍不成功,自己搞定了记录一下。

前言

NVIDIA驱动包含两个部分一个是CUDA(具体是个啥,不清楚,必须安装上就对了),另一个是具体的驱动。
如果以deb包的形式呈现,那么就是如下两个包:

-rw-rw-r-- 1 ubuntu ubuntu 1212738714 Sep 23  2017 cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
-rw-rw-r-- 1 ubuntu ubuntu  102497768 May 18 09:45 nvidia-diag-driver-local-repo-ubuntu1604-384.145_1.0-1_amd64.deb

为什么要安装9.0版本呢?tensorflow指明要安装9.0以上版本,我就选了9.2的安装,安装好了训练时报错,找9.0的库文件;这不又折回来安装9.0版本的了。

安装CUDA Toolkit 9.0

sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
sudo reboot

需要从这里进行下载
https://developer.nvidia.com/cuda-90-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1604&target_type=deblocal
下载完成后

sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

需要注意的是这种安装方法,安装完成后不能使用nvcc --version。不过问题不大。

修改环境变量

在终端打开并修改.bashrc文件

vim ~/.bashrc

将如下内容添加到.bashrc文件末尾:

export CUDA_HOME=/usr/local/cuda-9.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export PATH=${CUDA_HOME}/bin:${PATH}
export CUPIT_LIB_PATH=${CUDA_HOME}/extras/CUPTI/lib64
export LD_LIBRARY_PATH=${CUPIT_LIB_PATH}:$LD_LIBRARY_PATH

查看安装结果

一定要看到如下结果后再进行

ubuntu@VM-0-13-ubuntu:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176
ubuntu@VM-0-13-ubuntu:~$ 

安装NVIDIA驱动

在这里选择适合自己的驱动https://www.nvidia.com/Download/Find.aspx,注意CUDA版本要和上面安装的一致(比如这里使用是9.0版本)

sudo dpkg -i nvidia-diag-driver-local-repo-ubuntu1604-384.145_1.0-1_amd64.deb

已经包含cuda-command-line-tools不需要再使用正面命令进行安装了

sudo apt-get install cuda-command-line-tools
sudo apt-get update
sudo reboot

重启之后查看安装结果

ubuntu@VM-0-13-ubuntu:~$ nvidia-smi
Tue Sep 11 15:58:11 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.37                 Driver Version: 396.37                    |
|-------------------------------+----------------------+----------------------+
| 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 P40           On   | 00000000:00:06.0 Off |                    0 |
| N/A   22C    P8     9W / 250W |      0MiB / 22919MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
ubuntu@VM-0-13-ubuntu:~$ ls

本节来自:https://docs.nvidia.com/cuda/cuda-installation-guide-linux/

安装cuDNN

下载地址:https://developer.nvidia.com/cudnn
cuDNN需要安装三个deb包分别是Runtime LibraryDeveloper Library以及Code Samples

-rw-rw-r-- 1 ubuntu ubuntu  122730426 Jul 31 20:34 libcudnn7_7.2.1.38-1+cuda9.0_amd64.deb
-rw-rw-r-- 1 ubuntu ubuntu  112867596 Jul 31 20:34 libcudnn7-dev_7.2.1.38-1+cuda9.0_amd64.deb
-rw-rw-r-- 1 ubuntu ubuntu    4909666 Jul 31 20:34 libcudnn7-doc_7.2.1.38-1+cuda9.0_amd64.deb

Navigate to your directory containing cuDNN Debian file.
Install the runtime library, for example:

sudo dpkg -i libcudnn7_7.2.1.38-1+cuda9.0_amd64.deb

Install the developer library, for example:

sudo dpkg -i libcudnn7-dev_7.2.1.38-1+cuda9.0_amd64.deb

Install the code samples and the cuDNN Library User Guide, for example:

sudo dpkg -i libcudnn7-doc_7.2.1.38-1+cuda9.0_amd64.deb

校验是否安装成功

To verify that cuDNN is installed and is running properly, compile the mnistCUDNN sample located in the /usr/src/cudnn_samples_v7 directory in the debian file.

  1. Copy the cuDNN sample to a writable path.
$cp -r /usr/src/cudnn_samples_v7/ $HOME
  1. Go to the writable path.
$ cd  $HOME/cudnn_samples_v7/mnistCUDNN
  1. Compile the mnistCUDNN sample.
$ make clean && make
  1. Run the mnistCUDNN sample.
$ ./mnistCUDNN

If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following:

Test passed!

本节来源:https://docs.nvidia.com/deeplearning/sdk/cudnn-install/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

袁保康

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值