这个 tensorflow 消息是什么意思?有什么副作用吗?安装成功了吗?

use*_*789 10 python anaconda tensorflow

我刚刚在 anaconda python 上安装了 tensorflow v2.3。我尝试使用下面的 python 命令测试安装;

$ python -c "import tensorflow as tf; x = [[2.]]; print('tensorflow version', tf.__version__); print('hello, {}'.format(tf.matmul(x, x)))"
Run Code Online (Sandbox Code Playgroud)

我收到以下消息;

2020-12-15 07:59:12.411952: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
hello, [[4.]]
Run Code Online (Sandbox Code Playgroud)

从消息来看,似乎安装成功了。但究竟This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX AVX2是什么意思?

我是否使用具有某些有限功能的 tensorflow 版本?有什么副作用吗?

我正在使用 Windows 10。

mCo*_*ing 22

Tensorflow 的一个重要部分是它应该很快。通过合适的安装,它可以与 CPU、GPU 或 TPU 配合使用。部分快速意味着它根据您的硬件使用不同的代码。一些 CPU 支持其他 CPU 不支持的操作,例如向量化加法(一次添加多个变量)。Tensorflow 只是告诉您,您安装的版本可以使用 AVX 和 AVX2 操作,并且在某些情况下(例如在前向或后向传播矩阵乘法中)默认设置为这样做,这可以加快速度。这不是错误,它只是告诉您它可以并且将会利用您的 CPU 来获得额外的速度。

注意:AVX 代表高级矢量扩展。

  • 谢谢。听起来这是一件好事。不是一个值得担心的警告。其实,如果是好事,就没有必要输出消息来通知用户。我们中的一些人可能会感到担心。 (27认同)
  • @TheQuantumMan`导入操作系统;os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'` 请参阅:/sf/answers/2948532051/ (12认同)
  • 有没有办法隐藏此消息而不隐藏代码其余部分中的潜在错误? (9认同)
  • 是的,当我第一次尝试时,我也有过同样的抱怨。在我的世界里,没有消息就是好消息。 (7认同)
  • 只是为了确定,它已经优化了吗?或者我需要以某种方式主动启用它? (7认同)
  • 您的 Tensorflow 库是在没有这些打印标志的情况下制作的,应该使用这些标志重新编译,以充分发挥 Tensorflow 库的速度。 (3认同)

Fre*_*man 12

您可以使用以下方法禁用这些消息:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1' 

import tensorflow as tf
Run Code Online (Sandbox Code Playgroud)

来源: https: //stackoverflow.com/a/42121886


Jak*_*kub 7

消息

This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)
to use the following CPU instructions in performance-critical operations:  AVX AVX2
Run Code Online (Sandbox Code Playgroud)

意味着在性能很重要的地方(例如深度神经网络中的矩阵乘法),将使用某些优化的编译器指令。安装好像成功了。

oneDNN GitHub的库说:

oneAPI 深度神经网络库 (oneDNN) 是用于深度学习应用程序的基本构建块的开源跨平台性能库。该库针对英特尔架构处理器、英特尔处理器显卡和基于 Xe 架构的显卡进行了优化。oneDNN 对以下架构提供实验支持:

  • Arm* 64 位架构 (AArch64)
  • 英伟达* GPU
  • OpenPOWER* 电源 ISA (PPC64)
  • IBMz* (s390x)

  • 有没有办法隐藏此消息而不隐藏代码其余部分中的潜在错误? (6认同)
  • @TheQuantumMan - 我认为 /sf/answers/2948532051/ 回答了你的问题 (2认同)

Les*_*icz 7

我已经编译了 Tensorflow 库几次,如果您有类似以下内容:

kosinkie_l@Fedora ~/project/build $ python -c "import tensorflow as tf; x = [[2.]]; print('tensorflow version', tf.__version__); print('hello, {}'.format(tf.matmul(x, x)))"

2022-08-09 15:31:03.414926: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
tensorflow version 2.10.0-rc0
hello, Tensor("MatMul:0", shape=(1, 1), dtype=float32)
kosinkie_l@Fedora ~/project/build $
Run Code Online (Sandbox Code Playgroud)

这意味着CPU可以使用,但Tensorflow库不使用这些

这些消息可能会令人困惑 - 所以我选择了源代码(tensorflow/core/platform/cpu_feature_guard.cc:193),并且有以下内容:

131 #ifndef __AVX__
132     CheckIfFeatureUnused(CPUFeature::AVX, "AVX", missing_instructions);
133 #endif  // __AVX__
134 #ifndef __AVX2__
135     CheckIfFeatureUnused(CPUFeature::AVX2, "AVX2", missing_instructions);
136 #endif  // __AVX2__
...
192     if (!missing_instructions.empty()) {
193       LOG(INFO) << "This TensorFlow binary is optimized with "
194                 << "oneAPI Deep Neural Network Library (oneDNN) "
195                 << "to use the following CPU instructions in performance-"
196                 << "critical operations: " << missing_instructions << std::endl
197                 << "To enable them in other operations, rebuild TensorFlow "
198                 << "with the appropriate compiler flags.";
199     }
Run Code Online (Sandbox Code Playgroud)

该方法CheckIfFeatureUnused(CPUFeature::AVX, "AVX", missing_instructions)检查 CPU 是否可以执行 AVX 并将打印出的内容"AVX"放入missing_instructions collection