消除警告:This TensorFlow binary is optimized with oneAPI Deep...

时间:2022-12-15 11:56:39

AI入门级学习,大多数文章中优选推荐Keras,但是这个框架现在与TensorFlow简单绑定在一起(当然,你也可以选择另外的后端:如CNTK和Theano)。

今天看一门老旧的图书,输入如下代码时出现警告:

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

hello=tf.constant('HELLO, TENSORFLOW!')
print(hello)

警告详情如下:

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:  AVX2 FMA

To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

但是,程序仍然正常往下执行。网络搜索后,找到消除上述警告的方法是添加上面注释中的两行代码!

加入这两行代码,也就是把tensorflow的警告等级为2的警告忽略。