CPU version running TensorFlow adding os.environ['TF_CPP_MIN_LOG_LEVEL'] is invalid

report error

运行TensorFlow时,每次都会一堆爆红,虽然不影响,但是看那种很不舒服
W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cudart64_110.dll’; dlerror: cudart64_110.dll not found
I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-UU5OMQ5
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-UU5OMQ5
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: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
insert image description here

Solution

Since the CPU version is used and the GPU file is not used, the most direct solution found is to add the following statement to ignore this information:

#加入忽略
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'

Note : An error was reported after the first addition, and it was finally found that the order of addition was wrong. The above statement must be placed before import TensorFlow.

insert image description here

explain

os.environ["TF_CPP_MIN_LOG_LEVEL"] = '1' # 默认,显示所有信息 
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2' # 只显示 warning 和 Error
os.environ["TF_CPP_MIN_LOG_LEVEL"] = '3' # 只显示 Error

Guess you like

Origin blog.csdn.net/qq_43750528/article/details/128469403