import os import tensorflow as tf cores = 2 # Set the number of threads for OpenMP os.environ["OMP_NUM_THREADS"] = str(cores) os.environ["TF_NUM_INTRAOP_THREADS"] = str(cores) os.environ["TF_NUM_INTEROP_THREADS"] = str(cores) # Set TensorFlow threading configurations (optional, but good practice) tf.config.threading.set_intra_op_parallelism_threads(cores) tf.config.threading.set_inter_op_parallelism_threads(cores) # Your TensorFlow code goes here # ...