此 TensorFlow 二进制文件使用 oneAPI 深度神经网络库 (oneDNN) 进行了优化,以在性能关键的情况下使用以下 CPU 指令

Noa*_*ter 6 python tensorflow

我有以下代码:

import tensorflow as tf

print("Hello")
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:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Hello # This is printed about 5 seconds after the message
Run Code Online (Sandbox Code Playgroud)

我已经研究了这个线程和这个线程中消息的含义,但未能使其消失(并且无法在 5 秒内运行任何程序)。任何帮助将不胜感激。

Ton*_*nyM 7

该消息只是告诉您默认情况下会启用某些优化,如果您想要更多优化,可以重新编译 TF 以获得更高性能的优化。

\n

默认情况下,它们使用 AVX2 进行编译,AVX2 不是最快的 AVX,但它是最兼容的。

\n

如果您不需要启用这些(您可能不需要启用这些),那么您可以忽略该信息性消息,因为您知道您正在利用 oneDNN CPU 优化对运行进行一些优化。

\n

  • 您应该可以很好地使用 GPU。当请求 GPU 时,它应该使用该流(如果可用)。当它执行基于 CPU 的任务时,它只会使用 AVX2 指令。大多数情况下,它只是一个提示类型警告,而不是特定于您的代码路径或工具的使用。如果需要,您可以在 Windows 任务管理器中查看 GPU 利用率,或者在 Linux 上使用 nvidia-smi(显然对于 nvidia GPU :)) (2认同)