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

Set progressbar refresh rate in Google Colab #5516

Merged
merged 10 commits into from
Jan 19, 2021

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Jan 14, 2021

What does this PR do?

Fixes #5515

Colab example based on this branch:
https://colab.research.google.com/drive/1CX9WOkZPB5HtqOQD0_rHPeaOa9Cca-1g?usp=sharing

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified
  • Check that target branch and milestone match!

@awaelchli awaelchli added design Includes a design discussion callback feature Is an improvement or enhancement labels Jan 14, 2021
@awaelchli awaelchli added this to the 1.2 milestone Jan 14, 2021
@awaelchli awaelchli added the docs Documentation related label Jan 14, 2021
@awaelchli awaelchli marked this pull request as ready for review January 14, 2021 17:56
@rohitgr7
Copy link
Contributor

so refresh_rate is 1 now just because of the colab thing? The warning is raised during Trainer init itself, so isn't it better than setting it to 1 in other cases?

@awaelchli
Copy link
Contributor Author

so refresh_rate is 1 now just because of the colab thing?

no, the other way around. It is always one (as it was before) except when in colab and except the user sets it to the value they want.
I was requested to remove the warning

@rohitgr7
Copy link
Contributor

so refresh_rate is 1 now just because of the colab thing?

no, the other way around. It is always one (as it was before) except when in colab and except the user sets it to the value they want.
I was requested to remove the warning

ok my bad... got confused it with log_every_n_steps.

@codecov
Copy link

codecov bot commented Jan 14, 2021

Codecov Report

Merging #5516 (f776243) into release/1.2-dev (8566f69) will increase coverage by 4%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##           release/1.2-dev   #5516    +/-   ##
================================================
+ Coverage               89%     93%    +4%     
================================================
  Files                  153     153            
  Lines                10813   11088   +275     
================================================
+ Hits                  9615   10261   +646     
+ Misses                1198     827   -371     

@awaelchli awaelchli added the ready PRs ready to be merged label Jan 14, 2021
@awaelchli awaelchli linked an issue Jan 15, 2021 that may be closed by this pull request
@Borda Borda enabled auto-merge (squash) January 15, 2021 08:14
@@ -219,7 +219,7 @@ def __init__(
process_position: orders the progress bar when running multiple models on same machine.

progress_bar_refresh_rate: How often to refresh progress bar (in steps). Value ``0`` disables progress bar.
Ignored when a custom callback is passed to :paramref:`~Trainer.callbacks`.
Ignored when a custom progress bar is passed to :paramref:`~Trainer.callbacks`. Default: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is confusing as you say default but in code is none, so maybe tell that it is set internally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should I do?
we have other trainer args set as None and they are internally set to the defaults

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but usually this is only done for one of the following reasons:

1.) We need to check for some type before setting the default (for example to raise deprecation warnings)
2.) They are mutable otherwise.
3.) They depend on other parameters
4.) They are really hard to parse/set correctly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general the 2) is most common

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, here we are in case 3, because the default depends on an environment variable.
Then I will just update the docstring, or do you request other changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated docstring, do you like it better?

UserWarning
)
def configure_progress_bar(self, refresh_rate=None, process_position=0):
if os.getenv('COLAB_GPU') and refresh_rate is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this env always set for colab? also on TPU?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's '0' otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohitgr7 not according to my quick testing.
https://colab.research.google.com/drive/1_W9Dk-cxbBZmg6R2tNrqu3gzpjcEPjdb?usp=sharing
I get True back on CPU, GPU, and TPU even after restarting the runtime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's changed now. Last time I checked it was '1' for GPU and '0' for others.

@@ -219,7 +219,7 @@ def __init__(
process_position: orders the progress bar when running multiple models on same machine.

progress_bar_refresh_rate: How often to refresh progress bar (in steps). Value ``0`` disables progress bar.
Ignored when a custom callback is passed to :paramref:`~Trainer.callbacks`.
Ignored when a custom progress bar is passed to :paramref:`~Trainer.callbacks`. Default: 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but usually this is only done for one of the following reasons:

1.) We need to check for some type before setting the default (for example to raise deprecation warnings)
2.) They are mutable otherwise.
3.) They depend on other parameters
4.) They are really hard to parse/set correctly

Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@tchaton tchaton disabled auto-merge January 19, 2021 11:51
@tchaton tchaton enabled auto-merge (squash) January 19, 2021 11:51
@tchaton tchaton disabled auto-merge January 19, 2021 15:45
@tchaton tchaton enabled auto-merge (squash) January 19, 2021 15:45
@tchaton tchaton merged commit 24462dc into release/1.2-dev Jan 19, 2021
@tchaton tchaton deleted the feature/colab-refresh branch January 19, 2021 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
callback design Includes a design discussion docs Documentation related feature Is an improvement or enhancement ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve handling progressbar refresh rate in Google Colab
7 participants