您的CPU支持该TensorFlow二进制文件未编译为使用的指令:AVX AVX2[通俗易懂]

您的CPU支持该TensorFlow二进制文件未编译为使用的指令:AVX AVX2[通俗易懂]IamnewtoTensorFlow.我是TensorFlow的新手。Ihaverecentlyinstalledit(WindowsCPUversion)andrec

大家好,又见面了,我是你们的朋友全栈君。

本文翻译自:Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

I am new to TensorFlow. 我是TensorFlow的新手。 I have recently installed it (Windows CPU version) and received the following message: 我最近安装了它(Windows CPU版本),并收到以下消息:

Successfully installed tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc2 成功安装tensorflow-1.4.0 tensorflow-tensorboard-0.4.0rc2

Then when I tried to run 然后当我尝试跑步

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()

(which I found through https://github.com/tensorflow/tensorflow ) (我通过https://github.com/tensorflow/tensorflow找到)

I received the following message: 我收到以下消息:

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] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 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

But when I ran 但是当我跑步时

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

it ran as it should and output Hello, TensorFlow! 它按Hello, TensorFlow!运行并输出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? 您知道问题是什么以及如何解决?


#1楼

参考:https://stackoom.com/question/3BUij/您的CPU支持该TensorFlow二进制文件未编译为使用的指令-AVX-AVX


#2楼

What is this warning about? 这是什么警告?

Modern CPUs provide a lot of low-level instructions, besides the usual arithmetic and logic, known as extensions, eg SSE2, SSE4, AVX, etc. From the Wikipedia : 现代CPU提供大量的低级别的指示,除了一般的算术和逻辑,被称为扩展,例如SSE2,SSE4,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. Advanced Vector ExtensionsAVX )是Intel在2008年3月提出的针对Intel和AMD微处理器的x86指令集体系结构的扩展,并由Intel首先在2011年第一季度发布的Sandy Bridge处理器中得到支持,随后由AMD在Bulldozer处理器中发布。在2011年第三季度发布。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%). 特别是,AVX引入了融合乘法累加 (FMA)运算,从而加快了线性代数的计算速度,即点积,矩阵乘法,卷积等。几乎每个机器学习训练都涉及很多这些运算,因此将在支持AVX和FMA的CPU上速度更快(最高300%)。 The warning states that your CPU does support AVX (hooray!). 该警告指出您的CPU确实支持AVX(万岁!)。

I’d like to stress here: it’s all about CPU only . 我想在这里强调一下:这CPU有关。

Why isn’t it used then? 那为什么不使用呢?

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. 由于tensorflow默认发行版是在没有CPU扩展的情况下构建的,例如SSE4.1,SSE4.2,AVX,AVX2,FMA等。默认构建(来自pip install tensorflow )旨在与尽可能多的CPU兼容。 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. 另一个论点是,即使有了这些扩展,CPU也比GPU慢很多,并且期望在GPU上进行中型和大型的机器学习训练。

What should you do? 你该怎么办?

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). 如果您有GPU ,则不必在意AVX的支持,因为大多数昂贵的操作都会在GPU设备上调度(除非明确设置为不这样做)。 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'

… or by setting export TF_CPP_MIN_LOG_LEVEL=2 if you’re on Unix. …或者如果您在Unix上,则设置export TF_CPP_MIN_LOG_LEVEL=2 Tensorflow is working fine anyway, but you won’t see these annoying warnings. 无论如何,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. 如果没有GPU,并希望利用CPU尽可能的, 你应该与 AVX,AVX2 你的 CPU优化的源代码编译tensorflow,如果你的CPU支持他们启用了FMA。 It’s been discussed in this question and also this GitHub issue . 这个问题以及GitHub问题中都对此进行了讨论。 Tensorflow uses an ad-hoc build system called bazel and building it is not that trivial, but is certainly doable. Tensorflow使用一个称为bazel的临时构建系统,构建它并不是那么简单,但是肯定是可行的。 After this, not only will the warning disappear, tensorflow performance should also improve. 此后,不仅警告会消失,而且tensorflow性能也应提高。


#3楼

Update the tensorflow binary for your CPU & OS using this command 使用此命令为您的CPU和OS更新tensorflow二进制文件

pip install --ignore-installed --upgrade "Download URL"

The download url of the whl file can be found here 您可以在此处找到whl文件的下载网址

https://github.com/lakshayg/tensorflow-build https://github.com/lakshayg/tensorflow-build


#4楼

CPU optimization with GPU 使用GPU进行CPU优化

There are performance gains you can get by installing TensorFlow from the source even if you have a GPU and use it for training and inference. 即使您拥有GPU并将其用于训练和推理,也可以通过从源代码安装TensorFlow来获得性能提升。 The reason is that some TF operations only have CPU implementation and cannot run on your GPU. 原因是某些TF操作仅具有CPU实现,不能在您的GPU上运行。

Also, there are some performance enhancement tips that makes good use of your CPU. 此外,还有一些性能增强技巧可以充分利用您的CPU。 TensorFlow’s performance guide recommends the following: TensorFlow的性能指南建议以下内容:

Placing input pipeline operations on the CPU can significantly improve performance. 将输入管道操作放在CPU上可以显着提高性能。 Utilizing the CPU for the input pipeline frees the GPU to focus on training. 在输入管道中使用CPU将使GPU腾出精力来进行培训。

For best performance, you should write your code to utilize your CPU and GPU to work in tandem, and not dump it all on your GPU if you have one. 为了获得最佳性能,您应该编写代码以利用CPU和GPU协同工作,如果有的话,不要将其全部转储到GPU上。 Having your TensorFlow binaries optimized for your CPU could pay off hours of saved running time and you have to do it once. 为您的CPU优化TensorFlow二进制文件可以节省数小时的运行时间,因此您只需执行一次。


#5楼

For Windows (Thanks to the owner f040225), go to here: https://github.com/fo40225/tensorflow-windows-wheel to fetch the url for your environment based on the combination of “tf + python + cpu_instruction_extension”. 对于Windows(感谢所有者f040225),请转到此处: https : //github.com/fo40225/tensorflow-windows-wheel,以结合“ tf + python + cpu_instruction_extension”为您的环境获取URL。 Then use this cmd to install: 然后使用此cmd进行安装:

pip install --ignore-installed --upgrade "URL"

If you encounter the “File is not a zip file” error, download the .whl to your local computer, and use this cmd to install: 如果遇到“文件不是zip文件”错误,请将.whl下载到本地计算机,然后使用此cmd进行安装:

pip install --ignore-installed --upgrade /path/target.whl

#6楼

For Windows, you can check the official Intel MKL optimization for TensorFlow wheels that are compiled with AVX2. 对于Windows,您可以检查由AVX2编译的TensorFlow车轮的官方英特尔MKL优化 This solution speeds up my inference ~x3. 此解决方案加快了我的推断速度,达到x3。

conda install tensorflow-mkl
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/145177.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • acwing-396. 矿场搭建(Tarjan点双连通分量)「建议收藏」

    acwing-396. 矿场搭建(Tarjan点双连通分量)「建议收藏」煤矿工地可以看成是由隧道连接挖煤点组成的无向图。为安全起见,希望在工地发生事故时所有挖煤点的工人都能有一条出路逃到救援出口处。于是矿主决定在某些挖煤点设立救援出口,使得无论哪一个挖煤点坍塌之后,其他挖煤点的工人都有一条道路通向救援出口。请写一个程序,用来计算至少需要设置几个救援出口,以及不同最少救援出口的设置方案总数。输入格式输入文件有若干组数据,每组数据的第一行是一个正整数 N,表示工地的隧道数。接下来的 N 行每行是用空格隔开的两个整数 S 和 T,表示挖煤点 S 与挖煤点 T 由隧道直接连

    2022年8月10日
    9
  • 谈谈CompoundButton的OnCheckedChangeListener

    谈谈CompoundButton的OnCheckedChangeListenerCompoundButton相信大家都很熟悉了。OnCheckedChangeListener相信大家也很熟悉。不过不知道大家有没有碰到类似的问题:在某个CompoundButton.OnCheckedChangeListener中请求网络接口。在其他一些地方,例如onCreate/onCreateView/setUserVisableHint等等方法中,从另一个接口取得数据,

    2022年5月2日
    68
  • 什么是UE4(学ue4还是unity)

    对于游戏的来说,最能够影响它的性能的,便是游戏程序的开发、维护工作了。游戏开发、维护工作都是通过游戏开发引擎来完成的,而U3D和UE4正是如今行业主流的两款游戏开发引擎。不同的游戏开发引擎在不同的游戏中使用,那么具体的u3d和ue4的区别是什么?小编常被想要进入游戏行业的同学问到,学U3D和UE4哪个更好?其实这主要是看你自己的就业倾向。下面小编就从两款游戏开发引擎的具体区别来讲讲我们该如何选择。…

    2022年4月14日
    59
  • charles打断点有什么用_charles打断点后 如何执行

    charles打断点有什么用_charles打断点后 如何执行前言Charles是收费软件,可以免费试用30天。试用期过后,未付费的用户仍然可以继续使用,但是每次使用时间不能超过30分钟,并且启动时将会有10秒种的延时。此时,我们只需网上找一个注册码即可解

    2022年7月29日
    12
  • makefile中的include的作用(makefile中的变量)

    1、wildcard:扩展通配符2、notdir:去除路径3、patsubst:替换通配符例子:建立一个测试目录,在测试目录下建立一个名为sub的子目录$mkdirtest$cdtest$mkdirsub在test下,建立a.c和b.c2个文件,在sub目录下,建立sa.c和sb.c2个文件建立一个简单的Makef

    2022年4月18日
    103
  • mysql ddl操作(mysql查询条件执行顺序)

    由于mysql在线ddl(加字段、加索引等修改表结构之类的操作)过程如下: A.对表加锁(表此时只读)B.复制原表物理结构C.修改表的物理结构D.把原表数据导入中间表中,数据同步完后,锁定中间表,并删除原表E.rename中间表为原表F.刷新数据字典,并释放锁普遍,对于大表的处理,目前没有特别好的解决方案。大部分公司都会有个瞬断的过程。

    2022年4月11日
    86

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号