tensorflow的github地址:https://github.com/tensorflow/tensorflow
一、下载whl文件
进入该网址,下载对应版本的tensorflow文件。我安装的是Linux GPU: python2版本的,格式为whl
安装GPU版本的tensorflow需要预装cuda驱动与cudnn,详见我的另外两篇博客:
ubuntu14.04+cuda7.5安装 官方步骤版
ubuntu14.04更改cudnn版本
二、安装tensorflow
sudo pip install /home/ubuntu/Downloads/tensorflow_gpu-1.2.0rc0-cp27-none-linux_x86_64.whl
更换你自己的路径与文件名
此时安装路径为 /usr/local/lib/python2.7/dist-packages/
三、测试
在终端
python
import tensorflow as tf
四、可能会出现的错误
1、 Can’t import name symbol_database
原因:这是由于你的protobuf文件出错
解决:下载一个最新版本的protobuf,然后替换系统文件
#将老版本的google进行剪切备份
cd /usr/lib/python2.7/dist-packages/google
sudo mv google google_old
#移植新版本(把新下载的protobuf目录下的google复制到/usr/lib/python2.7/dist-packages/)
git clone https://github.com/google/protobuf.git
cd protobuf
cd python
sudo cp -R google /usr/lib/python2.7/dist-packages/
2、tensorflow RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
原因:系统中含有多个numpy,并且当前的numpy不能被使用
解决:查找numpy路径,把该版本的numpy给备份
python
import numpy
print numpy.__path__
此时显示当前使用的numpy的位置,如[‘/usr/local/lib/python2.7/dist-packages/numpy’]
#对该版本numpy进行备份,即让系统找不到该版本numpy,(也可以直接删除)
cd /usr/local/lib/python2.7/dist-packages
sudo mv numpy numpy_old
3、AttributeError: type object ‘NewBase’ has no attribute ‘is_abstract’
原因:此问题为six模块出现的问题
解决:更新six模块到最新版本
先查看你的电脑中six模块在哪个位置,绝大部分在/usr/lib/python2.7/dist-packages/
也有在/usr/local/lib/python2.7/dist-packages/
更新:
sudo pip install six --upgrade --target="/usr/lib/python2.7/dist-packages"
或者
sudo pip install six --upgrade --target="/usr/local/lib/python2.7/dist-packages"
参考:
http://blog.csdn.net/jiangda_0_0/article/details/52608632
http://blog.csdn.net/YhL_Leo/article/details/51280087