Python TensorFlow 没有被编译为使用 SSE(等)指令,但这些是可用的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43134753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 22:34:19  来源:igfitidea点击:

TensorFlow wasn't compiled to use SSE (etc.) instructions, but these are available

pythonpython-3.xtensorflow

提问by Jsleshem

I am running TensorFlow for the first time and using some example code. I got this error when running my code. Does anybody know why this happened, and how to fix it? Thanks!

我是第一次运行 TensorFlow 并使用一些示例代码。运行我的代码时出现此错误。有谁知道为什么会发生这种情况,以及如何解决它?谢谢!

2017-03-31 02:12:59.346109: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-03-31 02:12:59.346968: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-03-31 02:12:59.346975: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow libbrary wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-03-31 02:12:59.346979: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-03-31 02:12:59.346983: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-03-31 02:12:59.346987: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-03-31 02:12:59.346991: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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-03-31 02:12:59.346995: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\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.

回答by GPhilo

Those are warnings, not errors (as indicated by the Wafter the colon. Errors have an Ethere).

这些是警告,而不是错误(如W冒号后面的指示。错误有一个E那里)。

The warnings refer to the fact that your CPU supports SSE Instructions, which allow some fast in-hardware-parallel operations. Enabling these operations is a compile-time operation (i.e. to use SSE you need to build the library from the source enabling the specific SSE version you're targeting), in which case you might take a look at this question.

警告是指您的 CPU 支持SSE 指令这一事实,它允许一些快速的硬件并行操作。启用这些操作是一个编译时操作(即要使用 SSE,您需要从源构建库以启用您所针对的特定 SSE 版本),在这种情况下,您可以查看此问题

Note, however, that SSE support influences only the computation speed. Tensorflow will work with or without SSE, but it might take longer for your code to run. Note, also, that this influences only the CPU. If you're using the GPU build of Tensorflow, all the operations run on the GPU will not benefit of SSE instructions.

但是请注意,SSE 支持仅影响计算速度。Tensorflow 可以使用或不使用 SSE,但您的代码运行可能需要更长的时间。另请注意,这仅影响 CPU。如果您使用的是 Tensorflow 的 GPU 版本,则在 GPU 上运行的所有操作都不会受益于 SSE 指令。

回答by nanangarsyad

To hide those warnings, you could do this before your actual code.

要隐藏这些警告,您可以在实际代码之前执行此操作。

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

for detailed discussion, please refer here https://github.com/tensorflow/tensorflow/issues/7778

详细讨论请参考这里https://github.com/tensorflow/tensorflow/issues/7778

I hope, it can be a help for the other. :)

我希望,它可以对其他人有所帮助。:)

回答by Aashish

This isn't an error, just warnings saying if you build TensorFlow from the source it can be faster on your machine.

这不是错误,只是警告说如果您从源代码构建 TensorFlow,它在您的机器上会更快。

And just like the warnings say, you should only compile TF with these flags if you need to make TF faster.

就像警告所说的那样,如果您需要使 TF 更快,您应该只使用这些标志编译 TF。

You can use TF environment variable TF_CPP_MIN_LOG_LEVELand it works as follows:

您可以使用 TF 环境变量TF_CPP_MIN_LOG_LEVEL,它的工作原理如下:

  • It defaults to 0, displaying all logs
  • To filter out INFOlogs set it to 1
  • WARNINGSadditionally, 2
  • and to additionally filter out ERRORlogs set it to 3
  • 默认为0,显示所有日志
  • 要过滤掉INFO日志,请将其设置为 1
  • WARNINGS另外,2
  • 并另外过滤掉ERROR日志将其设置为 3

So you can do the following to silence the warnings:

因此,您可以执行以下操作来使警告静音:

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

For more detail discussion you see How to compile tensorflow using SSE4.1, SSE4.2, and AVX.

有关更多详细讨论,请参阅如何使用 SSE4.1、SSE4.2 和 AVX 编译 tensorflow。