From 30db4eb8a44186658e9d363785693c2ec4777603 Mon Sep 17 00:00:00 2001 From: Ofek Shochat <50481015+OfekShochat@users.noreply.github.com> Date: Sun, 14 Mar 2021 10:40:42 +0200 Subject: [PATCH 1/4] Update tfprocess.py --- tf/tfprocess.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tf/tfprocess.py b/tf/tfprocess.py index 85086573..f863ad8a 100644 --- a/tf/tfprocess.py +++ b/tf/tfprocess.py @@ -159,10 +159,15 @@ 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': self.strategy = tf.distribute.MirroredStrategy() tf.distribute.experimental_set_strategy(self.strategy) + elif self.cfg['gpu'].__contains__(','): + gpus = tf.config.experimental.list_physical_devices('GPU') + for i in self.cfg['gpu'].split(",") + tf.config.experimental.set_visible_devices(gpus[int(i)], + 'GPU') else: gpus = tf.config.experimental.list_physical_devices('GPU') print(gpus) From 3cf04f943699c446a3ee3353a6cbcdb1dc83871a Mon Sep 17 00:00:00 2001 From: Ofek Shochat <50481015+OfekShochat@users.noreply.github.com> Date: Sun, 14 Mar 2021 10:43:23 +0200 Subject: [PATCH 2/4] Update tfprocess.py --- tf/tfprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tf/tfprocess.py b/tf/tfprocess.py index f863ad8a..9823753d 100644 --- a/tf/tfprocess.py +++ b/tf/tfprocess.py @@ -165,7 +165,7 @@ def __init__(self, cfg): tf.distribute.experimental_set_strategy(self.strategy) elif self.cfg['gpu'].__contains__(','): gpus = tf.config.experimental.list_physical_devices('GPU') - for i in self.cfg['gpu'].split(",") + for i in self.cfg['gpu'].split(","): tf.config.experimental.set_visible_devices(gpus[int(i)], 'GPU') else: From d0c063282cefbd398f70ca1cec6bb4ff3dec8dd6 Mon Sep 17 00:00:00 2001 From: Ofek Shochat <50481015+OfekShochat@users.noreply.github.com> Date: Sun, 14 Mar 2021 10:57:03 +0200 Subject: [PATCH 3/4] Update tfprocess.py --- tf/tfprocess.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tf/tfprocess.py b/tf/tfprocess.py index 9823753d..f45ccb96 100644 --- a/tf/tfprocess.py +++ b/tf/tfprocess.py @@ -163,11 +163,13 @@ def __init__(self, cfg): if self.cfg['gpu'] == 'all': self.strategy = tf.distribute.MirroredStrategy() tf.distribute.experimental_set_strategy(self.strategy) - elif self.cfg['gpu'].__contains__(','): + elif "," in self.cfg['gpu']: + active_gpus = [] gpus = tf.config.experimental.list_physical_devices('GPU') for i in self.cfg['gpu'].split(","): - tf.config.experimental.set_visible_devices(gpus[int(i)], - 'GPU') + 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) From 5978c90ee32c80bd4e419cbcaa81bf2d5d248baa Mon Sep 17 00:00:00 2001 From: Ofek Shochat <50481015+OfekShochat@users.noreply.github.com> Date: Mon, 24 May 2021 15:29:12 +0300 Subject: [PATCH 4/4] Update tfprocess.py --- tf/tfprocess.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tf/tfprocess.py b/tf/tfprocess.py index f45ccb96..fe462197 100644 --- a/tf/tfprocess.py +++ b/tf/tfprocess.py @@ -160,10 +160,10 @@ def __init__(self, cfg): 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 self.cfg['gpu']: + elif "," in str(self.cfg['gpu']): active_gpus = [] gpus = tf.config.experimental.list_physical_devices('GPU') for i in self.cfg['gpu'].split(","):