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

问题描述 投票:0回答:8

我刚刚在 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)))"

我收到以下消息;

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.]]

从消息来看,似乎安装成功了。但

This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations:  AVX AVX2
到底是什么意思呢?

我使用的张量流版本是否具有一些有限的功能?有副作用吗?

我使用的是 Windows 10。

python tensorflow anaconda
8个回答
255
投票

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

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


17
投票

留言

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

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

oneDNN GitHub 存储库 说:

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

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

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 $

这意味着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     }

方法“CheckIfFeatureUnused(CPUFeature::AVX, "AVX",missing_instructions)”检查CPU是否可以执行AVX,并将“AVX”放入missing_instructions集合中,打印出来。


5
投票

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

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

import tensorflow as tf

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


3
投票

您必须创建新环境,或者尝试在当前基础环境的 GPU 中安装 Tensorflow,为此请使用以下命令...

创造新环境:

conda create --name py36 python==3.6.13 or any latest version

在CPU中安装tensorflow:

conda install tensorflow
conda install keras

在GPU中安装tensorflow:

conda install tensorflow-gpu
conda install tensorflow-estimator==2.1.0 or any latest version

希望对你有帮助,谢谢...


2
投票

当您使用预构建的 TensorFlow 二进制文件时,通常会出现此消息,该二进制文件不支持 AVX2 和 FMA CPU 指令,这可以显着加速某些操作。要利用这些说明,您需要使用适当的编译器标志从源代码构建 TensorFlow。

要解决此问题,您可以按照以下步骤操作:

  1. 安装必要的软件依赖项,例如Python、 TensorFlow 的构建依赖项和 C++ 编译器。

  2. 从官方存储库下载 TensorFlow 源代码。

  3. 使用适当的标志配置构建,以启用对 AVX2 和 FMA 指令的支持。您可以通过传递来做到这一点 --config=opt 标记到 ./configure 脚本。

  4. 通过运行 bazel

    build //tensorflow/tools/pip_package:build_pip_package
    命令从源代码构建 TensorFlow。

  5. 最后,通过运行安装新构建的 TensorFlow pip 包

    pip install /path/to/tensorflow_pkg.whl

完成这些步骤后,您应该拥有针对您的 CPU 进行优化并包含对 AVX2 和 FMA 指令的支持的 TensorFlow 版本。


-3
投票

当我在 Model.fit() 中使用 "verbose=0" 时,它发生了 然后我删除它就解决了


-12
投票

我执行了以下命令在CPUGPU上安装keras和tensorflow:

conda create --name py36 python==3.6.13
conda install tensorflow
conda install keras
conda install tensorflow-gpu
conda install tensorflow-estimator==2.1.0
© www.soinside.com 2019 - 2024. All rights reserved.