Published:07/30/2020 Last Updated:07/30/2020
Runtime settings can greatly affect the performance of TensorFlow* workloads running on CPUs, particularly regarding threading.
OpenMP* and TensorFlow both have settings that should be considered for their effect on performance. The Intel® Math Kernel Library for Deep Neural Networks (Intel® MKL-DNN) within the Intel® Optimization for TensorFlow* uses OpenMP settings as environment variables to affect performance on Intel CPUs. TensorFlow has a class (ConfigProto or config depeding on version) with settings that affect performance.
This guide will describe the settings, usage and how to apply the them.
These settings are applied as environment variables
export OMP_NUM_THREADS=16
import os
os.environ["OMP_NUM_THREADS"] = “16”
These settings are applied in Python* code using Config Proto or config
import tensorflow as tf
config = tf.ConfigProto(intra_op_parallelism_threads=16, inter_op_parallelism_threads=2, allow_soft_placement=True, device_count = {'CPU': 16})
session = tf.Session(config=config)
import tensorflow as tf
tf.config.threading.set_inter_op_parallelism_threads()
tf.config.threading.set_intra_op_parallelism_threads()
tf.config.set_soft_device_placement(enabled)
Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.
Intel technologies may require enabled hardware, software or service activation.
No product or component can be absolutely secure.
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.