您的CPU支持该TensorFlow二进制文件未编译为使用的指令:AVX AVX2 [英] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

查看:149
本文介绍了您的CPU支持该TensorFlow二进制文件未编译为使用的指令:AVX AVX2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是TensorFlow的新手.我最近安装了它(Windows CPU版本),并收到以下消息:

I am new to TensorFlow. I have recently installed it (Windows CPU version) and received the following message:

成功安装了tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc2

Successfully installed tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc2

然后当我尝试跑步时

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
sess.run(hello)
'Hello, TensorFlow!'
a = tf.constant(10)
b = tf.constant(32)
sess.run(a + b)
42
sess.close()

(我通过 https://github.com/tensorflow/tensorflow 找到)

我收到以下消息:

2017-11-02 01:56:21.698935:IC:\ tf_jenkins \ home \ workspace \ rel-win \ M \ windows \ PY \ 36 \ tensorflow \ core \ platform \ cpu_feature_guard.cc:137]您的CPU支持TensorFlow二进制文件未编译使用的指令:AVX AVX2

2017-11-02 01:56:21.698935: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

但是当我跑步

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

它按预期运行,并输出Hello, TensorFlow!,这表明安装确实成功,但是还有其他错误.

it ran as it should and output Hello, TensorFlow!, which indicates that the installation was successful indeed but there is something else that is wrong.

您知道问题出在哪里以及如何解决吗?

Do you know what the problem is and how to fix it?

推荐答案

此警告是关于什么的?

现代CPU除了提供通常的算术和逻辑功能外,还提供了许多低级指令,这些功能称为扩展,例如SSE2,SSE4,AVX等.摘自维基百科:

高级矢量扩展( AVX )是x86指令的扩展 英特尔和AMD提出的微处理器集架构 英特尔于2008年3月首次获得英特尔与桑迪的支持 桥接处理器将于2011年第一季度发布,随后由AMD随同 推土机处理器将于2011年第三季度发货.AVX提供了新功能, 新的指令和新的编码方案.

Advanced Vector Extensions (AVX) are extensions to the x86 instruction set architecture for microprocessors from Intel and AMD proposed by Intel in March 2008 and first supported by Intel with the Sandy Bridge processor shipping in Q1 2011 and later on by AMD with the Bulldozer processor shipping in Q3 2011. AVX provides new features, new instructions and a new coding scheme.

尤其是,AVX引入了融合乘法累加(FMA)操作,可加快线性代数的计算速度,即点积,矩阵乘法,卷积等.几乎每个机器学习训练都涉及大量这些操作,因此在具有以下功能的CPU上速度会更快支持AVX和FMA(最高300%).该警告表明您的CPU确实支持AVX(万岁!).

In particular, AVX introduces fused multiply-accumulate (FMA) operations, which speed up linear algebra computation, namely dot-product, matrix multiply, convolution, etc. Almost every machine-learning training involves a great deal of these operations, hence will be faster on a CPU that supports AVX and FMA (up to 300%). The warning states that your CPU does support AVX (hooray!).

我想在这里强调一下:这仅涉及 CPU .

I'd like to stress here: it's all about CPU only.

因为构建了tensorflow默认分发没有CPU扩展,例如SSE4.1, SSE4.2,AVX,AVX2,FMA等.默认版本(pip install tensorflow中的版本)旨在与尽可能多的CPU兼容.另一个论点是,即使有了这些扩展,CPU仍然比GPU慢很多,并且期望在GPU上进行中型和大型的机器学习培训.

Because tensorflow default distribution is built without CPU extensions, such as SSE4.1, SSE4.2, AVX, AVX2, FMA, etc. The default builds (ones from pip install tensorflow) are intended to be compatible with as many CPUs as possible. Another argument is that even with these extensions CPU is a lot slower than a GPU, and it's expected for medium- and large-scale machine-learning training to be performed on a GPU.

如果您有GPU ,则不必在乎AVX的支持,因为大多数昂贵的操作都将在GPU设备上分发(除非明确设置为不这样做).在这种情况下,您可以通过以下方式简单地忽略此警告:

If you have a GPU, you shouldn't care about AVX support, because most expensive ops will be dispatched on a GPU device (unless explicitly set not to). In this case, you can simply ignore this warning by

# Just disables the warning, doesn't enable AVX/FMA
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

...或通过设置export TF_CPP_MIN_LOG_LEVEL=2(如果您使用的是Unix).无论如何,Tensorflow都运行良好,但是您不会看到这些烦人的警告.

... or by setting export TF_CPP_MIN_LOG_LEVEL=2 if you're on Unix. Tensorflow is working fine anyway, but you won't see these annoying warnings.

如果您没有GPU ,并且想尽可能多地利用CPU,则您应该从针对您的 CPU优化的源构建tensorflow./strong>,并且启用了AVX,AVX2和FMA(如果您的CPU支持).在此问题 bazel 的临时构建系统,构建它并不是那么简单,但是肯定是可行的.此后,不仅警告会消失,而且tensorflow性能也将得到改善.

If you don't have a GPU and want to utilize CPU as much as possible, you should build tensorflow from the source optimized for your CPU with AVX, AVX2, and FMA enabled if your CPU supports them. It's been discussed in this question and also this GitHub issue. Tensorflow uses an ad-hoc build system called bazel and building it is not that trivial, but is certainly doable. After this, not only will the warning disappear, tensorflow performance should also improve.

这篇关于您的CPU支持该TensorFlow二进制文件未编译为使用的指令:AVX AVX2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆