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

fix gpus default for Trainer.add_argparse_args #6898

Merged
merged 12 commits into from
Apr 9, 2021
Merged

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Apr 8, 2021

What does this PR do?

Fixes #6549
Fixes #6263

The default for gpus and tpu_cores was a function, but it should be None as in the Trainer.
This fixes a pickle issue, when the function is passed into the model via Model(**vars(args)).
It would prevent unpickling outside pytorch lightning (or when PL code changes).

Newly added test case fails on master.

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

Did you have fun?

Make sure you had fun coding 🙃

@awaelchli awaelchli added the bug Something isn't working label Apr 8, 2021
@awaelchli awaelchli changed the title fix gpus default for Trainer.add_argparse_args fix gpus default for Trainer.add_argparse_args Apr 8, 2021
@awaelchli awaelchli added the checkpointing Related to checkpointing label Apr 8, 2021
@awaelchli awaelchli added the priority: 0 High priority task label Apr 8, 2021
@@ -232,7 +232,6 @@ def add_argparse_args(

if arg == 'gpus' or arg == 'tpu_cores':
use_type = _gpus_allowed_type
arg_default = _gpus_arg_default

Copy link
Contributor Author

@awaelchli awaelchli Apr 8, 2021

Choose a reason for hiding this comment

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

this is the fix.
we should not attach a function here, because if we pass it into our hparams, it will land in the checkpoint and risk not being able to unpickle.

Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

LGTM 😃

Copy link
Contributor

@carmocca carmocca left a comment

Choose a reason for hiding this comment

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

Do you have any idea why the default was a function?

@awaelchli
Copy link
Contributor Author

@carmocca totally no clue. Maybe someone confused it with the type, which can be a function that argparse uses to covert the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working checkpointing Related to checkpointing priority: 0 High priority task
Projects
None yet
4 participants