I've made a fresh install of Jupyter Notebook kernel and python packages, including tensorflow 2.4.1 (using miniconda env).
When I train and test a model, my CPU usage saturate. In my old install, that's not happen (low CPU usage), and the time to accomplish the tasks was barely the same.
Is there a config of jupyter and/or tensorflow? I've test on Jupyter Notebook and VSCode, the same problem occurs. Ubuntu 20.04 16GB RAM Intel® Core™ i5-8300H CPU @ 2.30GHz × 8
CPU usage when training a simple network model - htop view
Edit: Condition solved.
I've done a deep research on intel website, and found this link, about threading config. for Tensorflow and openMP. I run some quick tests varying the tensorflow 2.x section paramenters below, giving back no improvement.
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)
then I test the openMP settings, changing OMP_NUM_THREADS
from 0 to 8, as reported on the graph below:
training time vs OMP_NUM_THREADS
import os
os.environ["OMP_NUM_THREADS"] = “16”
CPU usage reduced, with lower training time.
CPU usage for OMP_NUM_THREADS equal to 0
OBS.: I am not an expert in ML benchmarks. Just fixed a network training parameters and topology for keras.Sequential()
model. Don't know the reason why my CPU was threading at maximum OMP_NUM_THREADS=16
by default.