摘要:Ubuntu17.04安装TensorFlow1.2的GPU版本。首先验证nvidia显卡,然后安装CUDA Toolkit 8.0,安装cuDNN v5深度神经网络计算加速库,最后通过python pip安装TensorFlow-GPU版本。
xiaolei@wang:~$ uname -m && cat /etc/*release
【CUDA官方下载】https://developer.nvidia.com/cuda-downloads
xiaolei@wang:~/Downloads$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
xiaolei@wang:~/Downloads$ sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-cublas-performance-update_8.0.61-1_amd64.deb
xiaolei@wang:~/Downloads$ sudo apt update
xiaolei@wang:~/Downloads$ sudo apt install cuda
NVIDIA cuDNN是用于深度神经网络的GPU加速库。
【原文】The NVIDIA CUDA® Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers. cuDNN is part of the NVIDIA Deep Learning SDK.
【官方下载】(需要注册登录后填写个小问卷才能下载)https://developer.nvidia.com/cudnn
xiaolei@wang:~/Downloads$ tar -zxf cudnn-8.0-linux-x64-v5.1.tgz && cd cuda
xiaolei@wang:~/Downloads/cuda$ sudo cp include/cudnn.h /usr/local/cuda-8.0/include/
xiaolei@wang:~/Downloads/cuda/lib64$ sudo cp lib64/libcudnn* /usr/local/cuda-8.0/lib64
xiaolei@wang:~$ sudo apt-get install libcupti-dev
#!/bin/sh
# Author:wangxiaolei 王小雷
# Blog: http://blog.csdn.net/dream_an
# Github: https://github.com/wangxiaoleiai
# Date: 201707
# Organization: https://github.com/whaleai
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64
可以通过python2或者python3的安装,博主使用的是python3。
xiaolei@wang:~$ sudo apt-get install python-pip python-dev # for Python 2.7
xiaolei@wang:~$ sudo apt-get install python3-pip python3-dev # for Python 3.n
xiaolei@wang:~$ pip install tensorflow-gpu # Python 2.7; GPU support
xiaolei@wang:~$ spip3 install tensorflow-gpu # Python 3.n; GPU support
xiaolei@wang:~$ python3
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
可以看到已经使用GPU了!完结-成功
xiaolei@wang:~$ sudo pip uninstall tensorflow # for Python 2.7 xiaolei@wang:~$ sudo pip3 uninstall tensorflow # for Python 3.n
https://www.tensorflow.org/install/install_sources#common_installation_problems