setup_rank0_logging#
- setup_rank0_logging(log_file=None)#
Set up logging that only prints to console from rank 0, but logs all ranks to files.
This is useful for distributed training where you want clean console output without duplicate messages from each rank, but still want detailed logs from all ranks saved to separate files.
- Parameters:
log_file (str | None) – Path to log file. If None, uses /tmp/rank_{rank}.log. The actual filename will have the rank appended (e.g., rank_0.log).
- Return type:
None
Example
>>> from nvsubquadratic.parallel.utils import setup_rank0_logging >>> setup_rank0_logging("/tmp/my_test.log") >>> logging.info("This only prints to console from rank 0")