1. windows下安装
建议基于anaconda安装. 参见 <<tensorflow (win10 & cuda &anaconda )安装>>.
http://blog.csdn.net/chuchus/article/details/77184566
2. centos下安装
按顺序一步一步解决依赖并安装。
1.1 python
笔者使用的版本为2.7.5 .2.1 python-pip
pip,Python Index Package。类似linux下的yum,安装并管理python软件包。pip安装命令: yum install python-pip python-devel
备注:不安装python-devel的话,pynum安装就会报错。这是一个py下的数学计算扩展包。
3.1 tensorflow
终于开始安装它本身了。
tensorflow 安装命令:pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl
安装之后的升级命令: pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl安装过程需要持续近10分钟,因为有大量的编译工作。
3.测试安装成功与否
#tensorflowTest.py
import tensorflow as tf
hello = tf.constant('Hello,TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))
运行
python tensorflowTest.py ,若最终结果与下面两行一致,则恭喜你安装成功!附运行结果的截图,见图4-1.
//TensorFlow.py 运行结果
Hello, TensorFlow!
42
图3-1 linux下tensflow运行成功, windows也一样
4. 常见问题
运行的时候会有下面的警告信息输出, 但程序仍能运行.
大致原因是pip安装的是预编译 tensorflow 库, 没有针对当前的cpu体系进行优化.
2017-05-05 11:18:58.162500: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-05-05 11:18:58.162995: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-05 11:18:58.163347: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-05 11:18:58.164001: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-05 11:18:58.164352: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-05 11:18:58.164699: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-05 11:18:58.165029: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-05 11:18:58.165292: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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.