Skip to main content
 首页 » 编程设计

python之在 Keras 上使用 TensorFlow 后端时出现奇怪的输出(OMP : Info #xx KMP_AFFINITY)

2024年08月13日29小虾米

我使用带有 TensorFlow 后端的 Keras 来训练神经网络模型。这是一个简单的模型(来自教程),一切正常。模型预测它应该的方式。好像只有tensorflow在输出信息,不知道能不能放心忽略/什么意思。有人可以向我解释以下输出告诉我们什么吗?特别是所有以 OMP 开头的行我都不清楚。弃用警告并不真正让我担心。

Using TensorFlow backend. 
OMP: Info #212: KMP_AFFINITY: decoding x2APIC ids. 
OMP: Info #210: KMP_AFFINITY: Affinity capable, using global cpuid leaf 11 info 
OMP: Info #154: KMP_AFFINITY: Initial OS proc set respected: 0-7 
OMP: Info #156: KMP_AFFINITY: 8 available OS procs 
OMP: Info #157: KMP_AFFINITY: Uniform topology 
OMP: Info #179: KMP_AFFINITY: 1 packages x 4 cores/pkg x 2 threads/core (4 total cores) 
OMP: Info #214: KMP_AFFINITY: OS proc to physical thread map: 
OMP: Info #171: KMP_AFFINITY: OS proc 0 maps to package 0 core 0 thread 0  
OMP: Info #171: KMP_AFFINITY: OS proc 1 maps to package 0 core 0 thread 1  
OMP: Info #171: KMP_AFFINITY: OS proc 2 maps to package 0 core 1 thread 0  
OMP: Info #171: KMP_AFFINITY: OS proc 3 maps to package 0 core 1 thread 1  
OMP: Info #171: KMP_AFFINITY: OS proc 4 maps to package 0 core 2 thread 0  
OMP: Info #171: KMP_AFFINITY: OS proc 5 maps to package 0 core 2 thread 1  
OMP: Info #171: KMP_AFFINITY: OS proc 6 maps to package 0 core 3 thread 0  
OMP: Info #171: KMP_AFFINITY: OS proc 7 maps to package 0 core 3 thread 1  
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 5252 thread 0 bound to OS proc set 0 
WARNING: Logging before flag parsing goes to stderr. 
W0820 14:05:56.256548  5252 deprecation.py:323] From C:\Users\Gebruiker\Anaconda3\envs\Anaconda3.7\lib\site-packages\tensorflow\python\ops\nn_impl.py:180: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version. 
Instructions for updating: 
Use tf.where in 2.0, which has the same broadcast rule as np.where 
2019-08-20 14:05:56.449349: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations:  AVX AVX2 
To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags. 
2019-08-20 14:05:56.451182: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 8. Tune using inter_op_parallelism_threads for best performance. 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 13256 thread 1 bound to OS proc set 2 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 5064 thread 2 bound to OS proc set 4 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 8904 thread 3 bound to OS proc set 6 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 9408 thread 4 bound to OS proc set 1 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 14360 thread 5 bound to OS proc set 3 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 14616 thread 6 bound to OS proc set 5 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 2692 thread 7 bound to OS proc set 7 
OMP: Info #250: KMP_AFFINITY: pid 14400 tid 14172 thread 8 bound to OS proc set 0 

请您参考如下方法:

OpenMP 正在将线程绑定(bind)到您的 CPU 以运行。这只是后勤输出,我不会担心。您可以找到记录在案的类似输出 here .

The Intel® Compiler's OpenMP* runtime library has ability to bind OpenMP* threads to physical processing units.

This article will show you how to use KMP_AFFINITY environment variable extensions from the Intel Compiler, the high-level affinity interface, to determine the machine topology and assigns OpenMP* threads to the processors based upon their physical location in the machine.

Example 1:

You have one quad core system with Intel® Hyper-Threading Technology (Intel®HT Technology) enabled. By default, Intel compiler OpenMP* runtime libraries will create 8 threads, running freely on 8 logical processors provided by the operating system.

如上文所述,根据您的物理 CPU 配置,线程被分配给不同的内核。