GPU版Tensorflow安装 centos7 64位

cuda安装

1.uname -m && cat /etc/*release
2.gcc -version
3.wget http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-repo-rhel7-7.0-28.x86_64.rpm
( RPM是RedhatPackageManager的缩写,是由RedHat公司开发的软件包安装和管理程序,同Windows平台上的Uninstaller比较类似)
4.rpm -ivh cuda-repo-rhel7-7.0-28.x86_64.rpm #安装rpm包
5.yum install cuda
6.vim .bash_profile

PATH=$PATH:$HOME/bin:/usr/local/cuda/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64/
CUDA_HOME=/usr/local/cuda
export PATH
export LD_LIBRARY_PATH
export CUDA_HOME

7. nvcc -V i 查看nvcc编译器版本
8.reboot #重启系统让NVIDIA GPU加载刚刚安装的驱动
9.cat /proc/driver/nvidia/version

NVRM version: NVIDIA UNIX x86_64 Kernel Module 375.51 Wed Mar 22 10:26:12 PDT 2017
GCC version: gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)

10.安装CUDA样例程序
cuda-install-samples-8.0.sh


该命令已经在系统环境变量中,直接使用,dir为自定义目录;执行完该命令之后,如果成功,会在dir中生成一个 NVIDIA_CUDA-8.0_Samples 目录
11. 编译样例程序,校验CUDA安装

cd /wzy/NVIDIA_CUDA-8.0_Samples
make

12.运行样例程序
./deviceQuery
输出结果末端显示:

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 2, Device0 = Tesla M40, Device1 = Tesla M40
Result = PASS

./bandwidthTest
`Device 0: Tesla M40
Quick Mode

Host to Device Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)

Device to Host Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 12841.5

Device to Device Bandwidth, 1 Device(s)
PINNED Memory Transfers
Transfer Size (Bytes) Bandwidth(MB/s)
33554432 213213.8

Result = PASS
`
至此,CUDA安装校验完成

CUDNN安装

1.下载cudnn-8.0-linux-x64-v5.1.tgz nvidia官方网站必须要注册,不能直接wget
https://pan.baidu.com/s/1i515khB?errno=0&errmsg=Auth%20Login%20Sucess&&bduss=&ssnerror=0#list/path=%2F%E5%AE%89%E8%A3%85%E5%8C%85%2Fcuda&parentPath=%2F%E5%AE%89%E8%A3%85%E5%8C%85
2.解压缩
tar -xvf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local
这里假设/usr/local是cuda的安装目录

tensorflow1.0安装

1.yum install python-devel libffi-devel openssl-devel
2. 下载个pip
wget https://bootstrap.pypa.io/get-pip.py
3. python get-pip.py
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0-cp27-none-linux_x86_64.whl #CPU版本安装

pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp27-none-linux_x86_64.whl #GPU版本安装

GPU测试
>>import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally

这样就ok了

print tf.__version__
hello=tf.constant('hello world')
sess = tf.Session()
print(sess.run(hello))

你可能感兴趣的:(深度学习,机器学习,tensorflow)