Skip to content

Commit

Permalink
py2 to py3 bug and iface fix for pslib (#36102)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuizhiqing authored Sep 28, 2021
1 parent 53f9768 commit 0e07f20
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
15 changes: 8 additions & 7 deletions python/paddle/fluid/incubate/fleet/base/role_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,38 +383,38 @@ def _worker_num(self):
return the current number of worker
"""
if self._check_role_generation():
return self._get_size() / self._proc_per_node
return int(self._get_size() / self._proc_per_node)
return 0

def _server_num(self):
"""
return the current number of server
"""
if self._check_role_generation():
return self._get_size() / self._proc_per_node
return int(self._get_size() / self._proc_per_node)
else:
self.generate_role()
return self._get_size() / self._proc_per_node
return int(self._get_size() / self._proc_per_node)

def worker_index(self):
"""
return the index of worker
"""
if self._check_role_generation():
return self._rank / self._proc_per_node
return int(self._rank / self._proc_per_node)
else:
self.generate_role()
return self._get_size() / 2
return int(self._get_size() / 2)

def server_index(self):
"""
return the index of server
"""
if self._check_role_generation():
return self._rank / self._proc_per_node
return int(self._rank / self._proc_per_node)
else:
self.generate_role()
return self._get_size() / self._proc_per_node
return int(self._get_size() / self._proc_per_node)

def _all_reduce(self, input, output, mode="sum"):
"""
Expand Down Expand Up @@ -612,6 +612,7 @@ def __init__(self, **kwargs):
# set running status of http server
self._http_server_d["running"] = False
self._iface = self.__get_default_iface()
self._iface = "" if self._iface == "lo" else self._iface
# this environment variable can be empty
self._prefix = os.getenv("SYS_JOB_ID", "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def stop_worker(self):
self._role_maker._barrier_worker()
if self._role_maker.is_first_worker():
self._fleet_ptr.stop_server()
if self._heter_ptr:
self._heter_ptr.stop_xpu_service()
self._role_maker._barrier_worker()
self._role_maker._barrier_all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def _minimize(self,
"user_define_dump_filename", "")
opt_info["dump_fields_path"] = strategy.get("dump_fields_path", "")
opt_info["dump_param"] = strategy.get("dump_param", [])
gpus_env = os.getenv("FLAGS_selected_gpus")
gpus_env = os.getenv("FLAGS_selected_gpus", "0")
opt_info["worker_places"] = [int(s) for s in gpus_env.split(",")]
opt_info["use_ps_gpu"] = strategy.get("use_ps_gpu", False)
if server._server.downpour_server_param.downpour_table_param[
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/fluid/incubate/fleet/utils/hdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import time
import logging
import six
from . import fs
from .fs import FS, LocalFS, FSFileExistsError, FSFileNotExistsError, ExecuteError, FSTimeOut, FSShellCmdAborted
#from . import fs
from paddle.distributed.fleet.utils.fs import FS, LocalFS, FSFileExistsError, FSFileNotExistsError, ExecuteError, FSTimeOut, FSShellCmdAborted
from paddle.fluid import core
import functools

Expand Down

0 comments on commit 0e07f20

Please sign in to comment.