diff --git a/tf/tfprocess.py b/tf/tfprocess.py index 85086573..fe462197 100644 --- a/tf/tfprocess.py +++ b/tf/tfprocess.py @@ -159,10 +159,17 @@ def __init__(self, cfg): self.renorm_max_d = self.cfg['training'].get('renorm_max_d', 0) self.renorm_momentum = self.cfg['training'].get( 'renorm_momentum', 0.99) - - if self.cfg['gpu'] == 'all': + + if str(self.cfg['gpu']) == 'all': self.strategy = tf.distribute.MirroredStrategy() tf.distribute.experimental_set_strategy(self.strategy) + elif "," in str(self.cfg['gpu']): + active_gpus = [] + gpus = tf.config.experimental.list_physical_devices('GPU') + for i in self.cfg['gpu'].split(","): + active_gpus.append(int(i)) + self.strategy = tf.distribute.MirroredStrategy(active_gpus) + tf.distribute.experimental_set_strategy(self.strategy) else: gpus = tf.config.experimental.list_physical_devices('GPU') print(gpus)