xlm.utils.rank_zero
RankedLogger
Bases: LoggerAdapter
A multi-GPU-friendly python command line logger.
__init__(name=__name__, rank_zero_only=False, extra=None, stacklevel=2)
Initializes a multi-GPU-friendly python command line logger that logs on all processes with their rank prefixed in the log message.
:param name: The name of the logger. Default is __name__.
:param rank_zero_only: Whether to force all logs to only occur on the rank zero process. Default is False.
:param extra: (Optional) A dict-like object which provides contextual information. See logging.LoggerAdapter.
:param stacklevel: The stack level to use for finding the caller. Default is 2.
log(level, msg, *args, rank=None, **kwargs)
Delegate a log call to the underlying logger, after prefixing its message with the rank
of the process it's being logged from. If 'rank' is provided, then the log will only
occur on that rank/process.
:param level: The level to log at. Look at logging.__init__.py for more information.
:param msg: The message to log.
:param rank: The rank to log at.
:param args: Additional args to pass to the underlying logging function.
:param kwargs: Any additional keyword args to pass to the underlying logging function.
get_rank_zero_logger(name)
Get a multi-GPU-friendly python command line logger.
:param name: The name of the logger. :return: A multi-GPU-friendly python command line logger.