Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry-pick to 2.2 #37238

Merged
merged 3 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/paddle/distributed/fleet/elastic/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
import signal
import random

logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper())
logger = logging.getLogger("ELASTIC")
logger.setLevel(logging.INFO)
formatter = logging.Formatter(
fmt='%(name)s %(levelname)s %(asctime)s %(message)s')
ch = logging.StreamHandler()
ch.setFormatter(formatter)
logger.addHandler(ch)

ELASTIC_EXIT_CODE = 101

Expand Down
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 @@ -42,9 +42,12 @@
"scale_sparse_grad": None,
}

logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(message)s')
ch = logging.StreamHandler()
ch.setFormatter(formatter)
logger.addHandler(ch)


class DistributedOptimizerImplBase(object):
Expand Down Expand Up @@ -846,7 +849,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