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

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

问题描述

我在我的机器上安装了 tensorflow gpu.我在我的机器上安装了 CUDA 工具包 9.0 和 cuDNN 7.0.

当我完成这些步骤时从 https://www.tensorflow.org/install/install_windows 来测试我的安装.通过进入程序

<预><代码>>>>将张量流导入为 tf>>>hello = tf.constant('你好,TensorFlow!')>>>sess = tf.Session()

但我收到以下错误您的 CPU 支持未编译此 TensorFlow 二进制文件使用的指令:AVX2"错误.

你能告诉我如何解决吗?

<预><代码>>>>sess = tf.Session()2018-07-25 23:27:54.477511: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] 您的 CPU 支持该 TensorFlow 二进制文件未编译使用的指令:AVX22018-07-25 23:27:55.607237: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] 发现设备 0 的属性:名称:Quadro M2000 主要:5 次要:2 memoryClockRate(GHz):1.1625pciBusID:0000:03:00.0总内存:4.00GiB 空闲内存:3.34GiB2018-07-25 23:27:55.612178: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] 添加可见 GPU 设备:02018-07-25 23:27:55.977046: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] 具有强度 1 边缘矩阵的设备互连 StreamExecutor:2018-07-25 23:27:55.980238: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958] 02018-07-25 23:27:55.982308: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0: N2018-07-25 23:27:55.984488: IT:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1084] 创建 TensorFlow 设备 (/job:localhost/replica:0/task:0/device:GPU:0 具有 3069 MB 内存)->物理 GPU(设备:0,名称:Quadro M2000,pci 总线 ID:0000:03:00.0,计算能力:5.2)>>>打印(sess.run(你好))b'你好,TensorFlow!>>>打印(sess.run(你好))b'你好,TensorFlow!

解决方案

我也一直想知道这个警告是什么意思.快速浏览后,这是我发现的:Advance Vector Extensions 是将整数运算扩展到浮点数的指令.例如:FUSE MULTIPLY ADD.

引自上述来源融合乘加(有时称为 FMA 或 fmadd)是一种在一个步骤中执行的浮点乘加运算,并进行一次舍入.也就是说,在未融合乘加计算乘积 b×c 的情况下,将其舍入为 N 个有效位,将结果添加到 a,然后舍入为 N 个有效位,融合乘加将计算整个表达式 a+在将最终结果四舍五入到 N 个有效位之前,将 b×c 设置为其全精度."

如果您的编译器中未启用 AVX,则操作 a+bxc 将按顺序执行,而 avx 指令将其执行为一个操作单元.

似乎默认情况下,tensorflow 的构建标志不包括对 AVX 指令的支持,如 配置部分在从源页面安装时声明.

为了能够抑制此警告,您必须从 source 等构建 tensorflow配置部分,使用额外的这些附加标志

bazel build -c opt --copt=-mavx --copt=-mavx2

我怀疑默认情况下会省略这些标志,因为并非所有 CPU 都支持这些指令.

有关详细信息,请参阅此答案 和这个 github issue.

编辑

这里是您可以使用的构建的详尽列表,具体取决于您的警告得到,包括这个.

I install tensorflow gpu on my machine. I install CUDA toolkit 9.0 and cuDNN 7.0 on my machine.

And when I go thru the steps from https://www.tensorflow.org/install/install_windows to test my installation. By entering the program

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

But I get the following error "Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2" error.

Can you please tell me how can I fix it?

>>> sess = tf.Session()
2018-07-25 23:27:54.477511: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2018-07-25 23:27:55.607237: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1392] Found device 0 with properties:
name: Quadro M2000 major: 5 minor: 2 memoryClockRate(GHz): 1.1625
pciBusID: 0000:03:00.0
totalMemory: 4.00GiB freeMemory: 3.34GiB
2018-07-25 23:27:55.612178: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1471] Adding visible gpu devices: 0
2018-07-25 23:27:55.977046: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-07-25 23:27:55.980238: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:958]      0
2018-07-25 23:27:55.982308: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0:   N
2018-07-25 23:27:55.984488: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 3069 MB memory) -> physical GPU (device: 0, name: Quadro M2000, pci bus id: 0000:03:00.0, compute capability: 5.2)
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
>>> print(sess.run(hello))
b'Hello, TensorFlow!'

解决方案

I have also been wondering what this warning means. After making a quick tour, here is what i ve found: Adveance Vector Extensions are the instructions that extends integer operations to floating points numbers. Eg: FUSE MULTIPLY ADD.

citing from the above source "A fused multiply–add (sometimes known as FMA or fmadd) is a floating-point multiply–add operation performed in one step, with a single rounding. That is, where an unfused multiply–add would compute the product b×c, round it to N significant bits, add the result to a, and round back to N significant bits, a fused multiply–add would compute the entire expression a+b×c to its full precision before rounding the final result down to N significant bits."

if AVX is not enabled in your compiler, the operation a+bxc would be done sequential steps wheras avx instructions executes it into one operation unit.

It seems by default, the build flags of tensorflow, doesn't include the support for AVX instructions as the configuration section states in on install from source page.

To be able to suppress this warning, you have to build tensorflow from source and on the configuration part, use additional these additional flags

bazel build -c opt --copt=-mavx --copt=-mavx2

I suspect that these flags are omitted by default because not all cpus supports these instructions.

For more details, see this answer and this github issue.

EDIT

Here is an exaustive list of of build you can use depending on which warnings you are getting, including this one.

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

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