Ubuntu系统安装cudn与cudnn

一、cudn安装

1、显卡驱动安装

apt-get update
apt-get install cuda-drivers

查看显卡信息

nvidia-smi

2、cudn安装

Ubuntu系统安装cudn与cudnn_第1张图片

   注意:选择runfile,其他的有些有坑。

  安装命令:

chmod +x cuda_9.0.176_384.81_linux.run
sudo ./cuda_9.0.176_384.81_linux.run --override

安装过程的选择:

Do you accept the previously read EULA?
accept/decline/quit: accept 

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: n (因为之前安装过显卡驱动,因而选择n)

Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-9.0 ]:

查看是否安装成功

nvcc -V
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
上述为成功安装,如果出现nvcc命令找不到,而使用“/usr/local/cuda/bin/nvcc -V”却可以运行,则需配置环境,否则为安装失败。

3、配置环境

vim ~/.zshrc 可以使用.bashrc
export PATH="/usr/local/cuda/bin:/usr/local/cuda-9.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH"

二、cuDnn安装

Download cuDNN v7.1.2 (Mar 21, 2018), for CUDA 9.0

    cuDNN v7.1.2 Runtime Library for Ubuntu16.04 (Deb)

    cuDNN v7.1.2 Developer Library for Ubuntu16.04 (Deb)

1、安装

sudo dpkg -i libcudnn7_7.1.2.21-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.1.2.21-1+cuda9.0_amd64.deb
sudo ldconfig
sudo updatedb
locate libcudnn

2、下载TensorFlow-gpu测试

sudo apt-get install libcupti-dev
pip install --upgrade tensorflow-gpu
     测试代码:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

b'Hello, TensorFlow!'


参考:

1、ubuntu16.04 NVIDIA CUDA8.0 以及cuDNN安装

2、1080ti+ubuntu17.10+Cuda9.1+cudnn7+tensorflow


你可能感兴趣的:(人工智能)