Reputation: 595
I have the following in my keras file at the top, I expect execution to be faster with this optimisation, is my assumption correct. I am running on an 8 core machine
NUM_PARALLEL_EXEC_UNITS =8
config = tf.compat.v1.ConfigProto(intra_op_parallelism_threads=NUM_PARALLEL_EXEC_UNITS, inter_op_parallelism_thr
eads=2, allow_soft_placement=True, device_count = {'CPU': NUM_PARALLEL_EXEC_UNITS })
session = tf.compat.v1.Session(config=config)
tf.compat.v1.keras.backend.set_session(session)
os.environ["OMP_NUM_THREADS"] = str(NUM_PARALLEL_EXEC_UNITS)
os.environ["KMP_BLOCKTIME"] = "30"
os.environ["KMP_SETTINGS"] = "1"
os.environ["KMP_AFFINITY"]= "granularity=fine,verbose,compact,1,0"
However when I run with this configuration, I still get the following message
WARNING:tensorflow:From rfbyolov3withextralayers.py:43: The name tf.keras.backend.set_session is deprecated. Please use tf.compat.v1.keras.backend.set_session instead.
2020-04-14 18:18:25.656076: I tensorflow/core/common_runtime/process_util.cc:147] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Can you please let me know why the warning still appears and also why the config values are ignored.
Each iteration is taking the same amoung of time with and without this optimization code
Upvotes: 1
Views: 643
Reputation: 595
I guess non of this v1 compat methods work.
I have achieved what I wanted to by doing this
tf.config.threading.set_inter_op_parallelism_threads(4)
Upvotes: 1