tensorflow 环境搭建(centos与windows) – yichudu – 博客频道 – CSDN.NET

官网教程地址: https://www.tensorflow.org/install/   .

1. 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分钟,因为有大量的编译工作。

2. windows下安装

注意一定要python 3.5.x版本.
其他步骤相似.

3.测试安装成功与否

[python] view plain copy

print?

  1. #tensorflowTest.py
  2. import tensorflow as tf
  3. hello = tf.constant(‘Hello,TensorFlow!’)
  4. sess = tf.Session()
  5. print(sess.run(hello))
  6. a = tf.constant(10)
  7. b = tf.constant(32)
  8. print(sess.run(a + b))
#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.

[html] view plain copy

print?

  1. //TensorFlow.py 运行结果
  2. Hello, TensorFlow!
  3. 42
//TensorFlow.py 运行结果

Hello, TensorFlow!

42

 

图3-1 linux下tensflow运行成功, windows也一样

4. 常见问题

运行的时候会有下面的警告信息输出, 但程序仍能运行.
大致原因是pip安装的是预编译 tensorflow 库, 没有针对当前的cpu体系进行优化.
[html] view plain copy

print?

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
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.

相关讨论可参照 stack Overflow, http://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions

来源URL:http://blog.csdn.net/chuchus/article/details/51713389