Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Logging with Accelerate

Accelerate has its own logging utility to handle logging while in a distributed system. To utilize this replace cases of logging with accelerate.logging:

- import logging
+ from accelerate.logging import get_logger
- logger = logging.getLogger(__name__)
+ logger = get_logger(__name__)

accelerate.logging.get_logger

< >

( name: str )

Parameters

  • name (str) — The name for the logger, such as __file__

Returns a logging.Logger for name that can handle multiprocessing.

If a log should be called on all processes, pass main_process_only=False

Example:

>>> from accelerate.logging import get_logger

>>> logger = get_logger(__name__)

>>> logger.info("My log", main_process_only=False)
>>> logger.debug("My log", main_process_only=True)