Ubuntu17.04 + cuda8.0 + cudnn 6.0 + gpu-tensorflow
1、检查显卡, 查看当前配置
uname -m &&cat /etc/*release
检查你的NVIDIA VGAcard model
sudo lshw -numeric-C display
nvidia-smi#显示信息
2、检查gcc(cuda 8.0 不支持v5.0之上的版本)
gcc --version
gcc 降版本
CUDA8.0 不支持 gcc 5.0 及以上的编译器,而系统自带的是5.4及以上版本,因此我们需要降版本,否则会在后面报错
在terminal中输入如下指令,将 gcc 版本降到 4.9
复制代码------根据自己自带的gcc版本改下列数字
sudo apt-get installg++-4.9
sudoupdate-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
sudoupdate-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
sudoupdate-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
sudoupdate-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
sudoupdate-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudoupdate-alternatives --set cc /usr/bin/gcc
sudoupdate-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudoupdate-alternatives --set c++ /usr/bin/g++
3、cuda 8.0
下载,安装和测试
Ubuntu17.04安装TensorFlow1.2的GPU版本
http://blog.csdn.net/dream_an/article/details/74992346
GTX1080Ti + cuda8.0 + cuDNN6.0 安装及测试
http://m.blog.csdn.net/zhangjunhit/article/details/73459019
设置环境变量----A
\ sudo gedit/etc/profile
打开/etc/profie文件,在文件末尾添加如下设置:
exportPATH=/usr/local/cuda-8.0/bin:$PATH
保存该文件,执行以下命令,使环境变量立即生效。
\$ source/etc/profile
http://m.blog.csdn.net/zhangjunhit/article/details/73459019
亦有环境配置----C
我们在terminal中键入下列命令:
sudo gedit ~/.bash_profile # 打开.bash_profile 这是用户的环境变量,不是全局的
然后在打开的文本末尾加入:
exportLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
exportCUDA_HOME=/usr/local/cuda
保存并关闭后,输入下列命令使环境变量生效:
source~/.bash_profile # 使被更改的环境变量生效
参考:Ubuntu 安装 tensorflow-gpu + keras
https://www.cnblogs.com/luruiyuan/p/6660142.html
设置变量----B
exportCUDA_HOME=/usr/local/cuda-8.0
exportPATH=$CUDA_HOME/bin:$PATH
exportLD_LIBRARY_PATH=$CUDA_HOME/lib64
可以都设置一遍!!
安装 libcupti-dev 包
sudo apt-get installlibcupti-dev
4、cudnn
CuDNN可以在官网免费获得,注册帐号后即可下载。
下载链接:https://developer.nvidia.com/cuDNN
账号:87
密码:l-12--+++T
参考:Ubuntu14.04CuDNN6.5安装
http://blog.csdn.net/honyniu/article/details/46388241
具体安装:
tar -xvfcudnn-8.0-linux-x64-v6.0.tgz
cd cuda/
sudo cp include/cudnn.h/usr/local/cuda/include
sudo cp -alib64/libcudnn* /usr/local/cuda/lib64
参考:cudnn6.0的安装简单教程
http://blog.csdn.net/w5688414/article/details/78195505
5、tensorflow
安装tensorflow-gpu
可以通过python2或者python3的安装,使用的是python3,二选一
安装依赖
xiaolei@wang:~$ sudoapt-get install python-pip python-dev #for Python 2.7
xiaolei@wang:~$ sudoapt-get install python3-pip python3-dev # for Python 3.n
安装tensorflow-gpu版本
xiaolei@wang:~$ pipinstall tensorflow-gpu # Python2.7; GPU support
xiaolei@wang:~$spip3 install tensorflow-gpu # Python 3.n; GPU support
测试tensorflow-gpu
python3
import tensorflow astf
hello =tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
参考:
Ubuntu17.04安装TensorFlow1.2的GPU版本