From a58df687a8df0fc4fe9b4058bb8e32f743a991ec Mon Sep 17 00:00:00 2001 From: dongdaxiang Date: Fri, 15 Mar 2019 11:52:17 +0800 Subject: [PATCH] only allow fleet to be initialized once --- .../fluid/incubate/fleet/parameter_server/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/incubate/fleet/parameter_server/__init__.py b/python/paddle/fluid/incubate/fleet/parameter_server/__init__.py index 4c1d97b57..cee409cde 100644 --- a/python/paddle/fluid/incubate/fleet/parameter_server/__init__.py +++ b/python/paddle/fluid/incubate/fleet/parameter_server/__init__.py @@ -29,14 +29,17 @@ class Fleet(object): self._opt_info = None # for fleet only self.role_maker_ = None self.local_ip_ = 0 + self.is_initialized_ = False def init(self): # TODO(guru4elephant) # this is a temporary solution # we will support more configurable RoleMaker for users in the future - self.role_maker_ = MPISymetricRoleMaker() - self.role_maker_.generate_role() - self._fleet_ptr = fluid.core.Fleet() + if not self.is_initialized_: + self.role_maker_ = MPISymetricRoleMaker() + self.role_maker_.generate_role() + self._fleet_ptr = fluid.core.Fleet() + self.is_initialized_ = True def stop(self): self.role_maker_.barrier_worker() -- GitLab