TensorFlow关于 SSE AVX的Warning问题

Posted 帝壹

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TensorFlow关于 SSE AVX的Warning问题相关的知识,希望对你有一定的参考价值。

从谷歌下载TensorFlow使用,在测试使用过程中,每次运行代码,都会输出一大堆的warning信息(见本文的最后部分),其大致意思是:本机CPU架构支持SSE、AVX等加速指令,而当前使用的TensorFlow库并没有充分利用这些指令集,如果能够使用开启了这些指令集的TensorFlow版本,则可以提高TensorFlow的执行效率。
就目前而言,查阅了谷歌的相关文档,提供的TensorFlow库还相对单一,没哟开启这么多指令集支持,其主要考虑的是让这些release版本的TensorFlow库可以安装在更多的计算机中使用,因为有很多老架构的cpu并不支持高级的指令集,比如AVX。
因此,如果想充分利用SSE和AVX来加速TensorFlow的CPU版本的运算,需要自己编译TensorFlow的源码。
另外,在StackOverflow中也找到了网友提供的用于暂时屏蔽这些warning输出的办法,如下:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tf

——————————-TensorFlow输出的关于CPU指令集SSE、AVX的warning信息————————————-

2017-08-01 17:14:18.620000: 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-08-01 17:14:18.620138: 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-08-01 17:14:18.620223: 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-08-01 17:14:18.620243: 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-08-01 17:14:18.620259: 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.
[array([ 14.], dtype=float32)]

以上是关于TensorFlow关于 SSE AVX的Warning问题的主要内容,如果未能解决你的问题,请参考以下文章

not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA

如何检查编译代码是否使用SSE和AVX指令?

安装tensorflow遇到:Your CPU supports instructions that this TensorFlow binary was not compiled to use(示例

tensorflow输出提示Your CPU supports instructions that this TensorFlow binary was not compiled to use: AV

1.0Tensorflow中出现编译问题的解决方案

SIMD指令集——一条指令操作多个数,SSE,AVX都是,例如:乘累加,Shuffle等

卡常头文件

Intel的AVX2指令集解读

tensorflow提示:此版本TensorFlow不支持AVX2但是你的cpu支持

tensorflow 安装: that this TensorFlow binary was not compiled to use: AVX AVX2