环境:Ubuntu16.04(64位)
Python2.7
一定要是64位系统,TensorFlow不支持32位!
参考官方的文档,我选择基于virtualenv安装,下面是步骤:
1.下载TensorFlow的whl文件,根据自己的实际环境来,我对应的是tensorflow-1.2.0rc1-cp27-cp27mu-manylinux1_x86_64.whl
2.安装必备的工具;
sudo apt-get install python-pip python-dev python-virtualenv
3.安装好以后,新建一个virtualenv环境;
virtualenv --system-site-packages ~/tensorflow #路径自己定义,我的是 ~/tensorFlow
cd ~/tensorflow #进入tensorFlow目录
4.激活virtualenv环境
source bin/activate
成功执行后命令行前面多了个” (tensorflow) ”
5.安装TensorFlow
pip install numpy #我有点方,所以先装个numpy
pip install tensorflow-1.2.0rc1-cp27-cp27mu-manylinux1_x86_64.whl
安装tensorflow时候要保持联网,虽然这个包已经下载好了,但是他还会下载一些依赖,讲道理的说numpy也会自动下载,但是为了确保,我首先手动把他安装了。(如果你没有改pip镜像源的话,在下载依赖时候可能报错http请求超时错误,可以选择重试几次,或者直接修改你的镜像源,改成国内的,我就不赘述了)。
6.完成。
声明:我最终成功的版本是在Ubuntu下新建了一个Python的virtualenv,然后在虚拟环境安装成功的。直接安装的二进制文件。所以这样安装后运行时可能会有警告:
2017-05-29 13:16:36.255629: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-29 13:16:36.256148: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-29 13:16:36.256570: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-29 13:16:36.256695: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-29 13:16:36.256765: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
这是我的提示信息,’ w ‘是warning的意思,同理,’ E ‘就是error。这堆警告大概就是说我没有编译SSE、AVX、FMA(这三个都是指令集),但是我的电脑支持这些指令集,如果我编译这些指令集可以提高运行速度。网上度了一下说如果编译这些指令集的话速度可以提升近一倍。