Python >> Tutoriel Python >  >> Python Tag >> Keras

Comment puis-je réduire le nombre de CPU utilisés par Tensorlfow/Keras ?

Dans Tensorflow 2.0, il n'y a plus de session. En exécution hâtive, utilisez directement l'API de configuration pour définir le parallélisme au démarrage du programme comme ceci.

import tensorflow as tf

tf.config.threading.set_intra_op_parallelism_threads(2)
tf.config.threading.set_inter_op_parallelism_threads(2)
with tf.device('/CPU:0'):
    model = tf.keras.models.Sequential([...

https://www.tensorflow.org/api_docs/python/tf/config/threading