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

查看:34
本文介绍了您的 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: f_jenkinshomeworkspace el-winMwindowsPY36 ensorflowcoreplatformcpu_feature_guard.cc:137] 你的 CPU 支持此 TensorFlow 二进制文件未编译为使用的说明:AVX AVX2

2017-11-02 01:56:21.698935: I C: f_jenkinshomeworkspace el-winMwindowsPY36 ensorflowcoreplatformcpu_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 指令的扩展由 Intel 和 AMD 提出的微处理器集架构英特尔于 2008 年 3 月首次获得英特尔与 Sandy 的支持桥接处理器于 2011 年第一季度及之后由 AMD 与Bulldozer 处理器于 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 take advantage of AVX/FMA to run faster
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 启用 AVX、AVX2 和 FMA(如果您的 CPU 支持它们).在这个问题这个 GitHub 问题.Tensorflow 使用一个名为 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天全站免登陆