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

Only print timer summary on rank 0 #394

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions examples/auto_unit_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def main(args: Namespace) -> None:
train_dataloader=train_dataloader,
eval_dataloader=eval_dataloader,
max_epochs=args.max_epochs,
auto_timing=True,
)

fit(state, my_unit)
Expand Down
3 changes: 2 additions & 1 deletion torchtnt/framework/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
_step_requires_iterator,
log_api_usage,
)
from torchtnt.utils.rank_zero_log import rank_zero_info
from torchtnt.utils.timer import get_timer_summary, Timer

logger: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -120,7 +121,7 @@ def evaluate(
_evaluate_impl(state, eval_unit, callbacks)
logger.info("Finished evaluation")
if state.timer:
logger.info(get_timer_summary(state.timer))
rank_zero_info(get_timer_summary(state.timer))
except Exception as e:
# TODO: log for diagnostics
logger.info(e)
Expand Down
3 changes: 2 additions & 1 deletion torchtnt/framework/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
_run_callback_fn,
log_api_usage,
)
from torchtnt.utils.rank_zero_log import rank_zero_info
from torchtnt.utils.timer import get_timer_summary, Timer

logger: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -149,7 +150,7 @@ def fit(
state._entry_point = EntryPoint.FIT
_fit_impl(state, unit, callbacks)
if state.timer:
logger.info(get_timer_summary(state.timer))
rank_zero_info(get_timer_summary(state.timer))
except Exception as e:
# TODO: log for diagnostics
logger.info(e)
Expand Down
3 changes: 2 additions & 1 deletion torchtnt/framework/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
_step_requires_iterator,
log_api_usage,
)
from torchtnt.utils.rank_zero_log import rank_zero_info
from torchtnt.utils.timer import get_timer_summary, Timer

logger: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -121,7 +122,7 @@ def predict(
_predict_impl(state, predict_unit, callbacks)
logger.info("Finished predict")
if state.timer:
logger.info(get_timer_summary(state.timer))
rank_zero_info(get_timer_summary(state.timer))
except Exception as e:
# TODO: log for diagnostics
logger.info(e)
Expand Down
3 changes: 2 additions & 1 deletion torchtnt/framework/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
_step_requires_iterator,
log_api_usage,
)
from torchtnt.utils.rank_zero_log import rank_zero_info
from torchtnt.utils.timer import get_timer_summary, Timer

logger: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -132,7 +133,7 @@ def train(
_train_impl(state, train_unit, callbacks)
logger.info("Finished train")
if state.timer:
logger.info(get_timer_summary(state.timer))
rank_zero_info(get_timer_summary(state.timer))
except Exception as e:
# TODO: log for diagnostics
logger.info(f"Exception during train\n: {e}")
Expand Down