Ubuntu 16.04 安装CUDA9.0和cuDNN7.4.1(亲测成功)

目录

一、安装CUDA

二、下载cuDNN

三、设置环境变量

四、查看安装是否成功


一、安装CUDA

1.博主这里选择9.0版本,CUDA历代版本下载的网址为:https://developer.nvidia.com/cuda-toolkit-archive

2.如下选择

                                                                                      

3.执行指令:


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

二、下载cuDNN

1.网址:https://developer.nvidia.com/rdp/cudnn-archive

2.选择7.4.1cuDNN Library for Linux下载

                                                                                    

3.解压:

sudo tar -zxvf cudnn-9.0-linux-x64-v7.4.1.5.tgz
 

                                                 

4.复制cuDNN的文件到已经安装好的目录中


  
  1. sudo cp cuda/include/cudnn.h /usr/local/cuda/include
  2. sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
  3. sudo chmod a+r /usr/local/cuda/include/cudnn.h
  4. sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

三、设置环境变量

1.编辑环境变量文件.bashrc

sudo gedit ~/.bashrc
 

2.最下面添加这几句话


  
  1. export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
  2. export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  3. export CUDA_HOME=/usr/local/cuda

四、查看安装是否成功

1.重启电脑/注销用户

2.打开终端,输入

nvcc -V
 

应该显示如下类似字样


  
  1. nvcc: NVIDIA (R) Cuda compiler driver
  2. Copyright (c) 2005-2017 NVIDIA Corporation
  3. Built on Fri_Sep__1_21:08:03_CDT_2017
  4. Cuda compilation tools, release 9.0, V9.0.176

3.输入

nvidia-smi
 

应该显示如下类似字样


  
  1. Wed May 15 19:50:57 2019
  2. +-----------------------------------------------------------------------------+
  3. | NVIDIA-SMI 384.130 Driver Version: 384.130 |
  4. |-------------------------------+----------------------+----------------------+
  5. | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
  6. | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
  7. |===============================+======================+======================|
  8. | 0 GeForce GTX 108... Off | 00000000:01:00.0 On | N/A |
  9. | 20% 39C P8 16W / 250W | 387MiB / 11169MiB | 1% Default |
  10. +-------------------------------+----------------------+----------------------+
  11. +-----------------------------------------------------------------------------+
  12. | Processes: GPU Memory |
  13. | GPU PID Type Process name Usage |
  14. |=============================================================================|
  15. | 0 1105 G /usr/lib/xorg/Xorg 219MiB |
  16. | 0 2062 G compiz 41MiB |
  17. | 0 2464 G /proc/self/exe 99MiB |
  18. | 0 3256 G ...passed-by-fd --v8-snapshot-passed-by-fd 24MiB |
  19. +-----------------------------------------------------------------------------+

说明CUDAcuDNN安装成功~(没有很可能是环境变量设置出了问题)

文章来源: nickhuang1996.blog.csdn.net,作者:悲恋花丶无心之人,版权归原作者所有,如需转载,请联系作者。

原文链接:nickhuang1996.blog.csdn.net/article/details/90243205

(完)