Linux下CUDA9.0+CUDNN9.0+Tensorflow1.8.0安装详解


一、环境参数
1、操作系统
centos7.x_64bit

[root@yyljxl tools]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

[root@yyljxl tools]# uname -r
3.10.0-514.el7.x86_64

2、需要python3.6环境
setuptools-19.6.tar.gz
pip-9.0.1.tar.gz
Python-3.6.7.tar.xz

#安装方法参考:
http://172.28.5.37/huzhihua/install_python3

3、检查环境
#去除nouveau驱动
lsmod | grep nouveau #执行上述命令,什么都不显示说明已经成功去除了nouveau驱动

#检查GPU是否识别
[root@yyljxl pip]# lspci | grep NV
00:0c.0 3D controller: NVIDIA Corporation GP100GL (rev a1)

#查看显卡信息
[root@yyljxl ~]# nvidia-smi
Sat May 18 11:38:54 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.81 Driver Version: 384.81 |
|-------------------------------+----------------------+----------------------+
| 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 P100-PCIE... Off | 00000000:00:0C.0 Off | 0 |
| N/A 59C P0 160W / 250W | 8615MiB / 16276MiB | 67% Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 2238 C python3 8601MiB |
+-----------------------------------------------------------------------------+

二、软件安装
2.1、所需软件版本(备注:软件要按顺序安装)
[root@yyljxl tools]# ll
total 3680468
nvidia-diag-driver-local-repo-rhel7-418.67-1.0-1.x86_64.rpm
cuda_9.0.176_384.81_linux.run
cudnn-9.0-linux-x64-v7.tgz
tensorflow-gpu==1.8.0

2.2、安装显卡驱动
#nvidia-diag-driver-local-repo-rhel7-418.67-1.0-1.x86_64.rpm
rpm -ivh nvidia-diag-driver-local-repo-rhel7-418.67-1.0-1.x86_64.rpm

2.3、安装cuda
#cuda_9.0.176_384.81_linux.run
#安装过程中会有提示:
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? (y)es/(n)o/(q)uit:n
注意:此步选择n,其余选y或者default即可。

2.4、配置环境变量
vi /etc/profile
export PATH=/usr/local/cuda-9.0/bin:$PATH

vi/etc/ld.so.conf
/usr/local/cuda-9.0/lib64

#使环境变量生效
source /etc/profile

#执行命令查看是否有输出:
[root@yyljxl ~]# ldconfig -v
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
ldconfig: Path `/usr/lib64' given more than once
ldconfig: Can't stat /usr/libx32: No such file or directory
/usr/lib64/iscsi:
libiscsi.so.2 -> libiscsi.so.2.0.10900
/usr/lib64/mysql:
libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
/usr/local/cuda-9.0/lib64:
libnppisu.so.9.0 -> libnppisu.so.9.0.176
libcufft.so.9.0 -> libcufft.so.9.0.176
libnvblas.so.9.0 -> libnvblas.so.9.0.176
libcudnn.so.7 -> libcudnn.so.7.0.5
libcufftw.so.9.0 -> libcufftw.so.9.0.176
libnppial.so.9.0 -> libnppial.so.9.0.176
libOpenCL.so.1 -> libOpenCL.so.1.0.0
libnvToolsExt.so.1 -> libnvToolsExt.so.1.0.0
省略部分.....

2.5、安装cudnn
tar xf cudnn-9.0-linux-x64-v7.tgz
cp cuda/include/cudnn.h /usr/local/cuda/include/
cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/ -d
chmod a+r /usr/local/cuda/include/cudnn.h
chmod a+r /usr/local/cuda/lib64/libcudnn*

2.6安装tensorflow-gpu==1.8.0
pip install tensorflow-gpu==1.8.0

#查看tensorflow的版本
python3
import tensorflow as tf
tf.__version__

示例:

[root@yyljxl tools]# python3
Python 3.6.7 (default, May 18 2019, 09:18:03) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf

tf.__version__>>> >>> 
'1.8.0'
>>> exit()

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM