[笔记] Ubuntu 18.04安装cuda 10及cudnn 7流程

安装环境

  • OS:Ubuntu 18.04 64 bit
  • 显卡:NVidia GTX 1080

任务:安装 CUDA 10及cuDNN 7

工具下载

NVidia官网下载下列文件:

CUDA 10:cuda_10.0.130_410.48_linux.run

cnDNN 7.4:cudnn-10.0-linux-x64-v7.4.2.24.tgz

安装CUDA

$ sudo sh cuda_10.0.130_410.48_linux.run

先输入accept接受协议,然后按需回答问题即可。

注意:

  • 如果当前显卡驱动版本高于CUDA安装包内的驱动,建议跳过这一步,保留原来的显卡驱动即可
  • 为了节省空间,sample可以不装

接着将下面内容追加到~/.bashrc

export PATH=/usr/local/cuda-10.0/bin:$PATH

验证CUDA

使用nvidia-smi查看驱动版本为415.23

$ nvidia-smi
Thu Jan 24 18:00:52 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 415.23 Driver Version: 415.23 CUDA Version: 10.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1080 Off | 00000000:01:00.0 On | N/A |
| 48% 35C P8 8W / 180W | 200MiB / 8116MiB | 2% Default |
+-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1462 G /usr/lib/xorg/Xorg 83MiB |
| 0 1600 G /usr/bin/gnome-shell 100MiB |
| 0 1794 G /opt/teamviewer/tv_bin/TeamViewer 14MiB |
+-----------------------------------------------------------------------------+

CUDA版本为10.0

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

安装cuDNN

流程是:解压,拷贝,配置环境变量

# 解压
$ tar -zxvf cudnn-10.0-linux-x64-v7.4.2.24.tgz # 拷贝
$ cd cudnn-10.0-linux-x64-v7.4.2.24
$ sudo cp cuda/include/cudnn.h /usr/local/cuda-10.0/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.0/lib64 # 修改权限
$ sudo chmod a+r /usr/local/cuda-10.0/include/cudnn.h /usr/local/cuda-10.0/lib64/libcudnn*

将下面内容追加到~/.bashrc

export PATH=/usr/local/cuda-10.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64:$LD_LIBRARY_PATH
export CUDNN_PATH="/usr/local/cuda-10.0/lib64/libcudnn.so"

验证cnDNN

下面命令不报错就OK。

$ echo -e '#include"cudnn.h"\n void main(){}' | nvcc -x c - -o /dev/null -lcudnn
上一篇:[ubuntu 18.04 + RTX 2070] Anaconda3 - 5.2.0 + CUDA10.0 + cuDNN 7.4.1 + bazel 0.17 + tensorRT 5 + Tensorflow(GPU)


下一篇:nginx重启无法找到PId的解决办法