Skip to content

Commit

Permalink
allow imagenet training profiling to be disabled in config
Browse files Browse the repository at this point in the history
Set option --config.profile=False on launch to disable.

PiperOrigin-RevId: 647843578
  • Loading branch information
levskaya authored and Flax Authors committed Jun 29, 2024
1 parent cb646c8 commit 7cd7020
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/imagenet/configs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def get_config():
# num_epochs using the entire dataset. Similarly for steps_per_eval.
config.num_train_steps = -1
config.steps_per_eval = -1

# whether to profile the training loop
config.profile = True

return config


Expand Down
4 changes: 2 additions & 2 deletions examples/imagenet/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ def train_and_evaluate(

train_metrics = []
hooks = []
if jax.process_index() == 0:
hooks += [periodic_actions.Profile(num_profile_steps=5, logdir=workdir)]
if jax.process_index() == 0 and config.profile:
hooks += [periodic_actions.Profile(num_profile_steps=3, logdir=workdir)]
train_metrics_last_t = time.time()
logging.info('Initial compilation, this might take some minutes...')
for step, batch in zip(range(step_offset, num_steps), train_iter):
Expand Down

0 comments on commit 7cd7020

Please sign in to comment.