Skip to content

Enabled partial checkpoint loading #1936

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

Merged
merged 5 commits into from
Apr 4, 2021
Merged

Enabled partial checkpoint loading #1936

merged 5 commits into from
Apr 4, 2021

Conversation

danieltudosiu
Copy link
Contributor

@danieltudosiu danieltudosiu commented Apr 3, 2021

Description

Allowing partial loading of a model via strict=False.

fixes #1891

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

danieltudosiu and others added 2 commits April 3, 2021 21:23
Allowing partial loading of a model via strict=False.

Signed-off-by: Petru-Daniel Tudosiu <[email protected]>
@danieltudosiu
Copy link
Contributor Author

@Nic-Ma if I check the error of the check and I do what it asks I get

AttributeError: module 'ignite' has no attribute '__version__'

I installed the requirements based on requirements-dev.txt.

What should I do?

@wyli
Copy link
Contributor

wyli commented Apr 3, 2021

/black

@danieltudosiu
Copy link
Contributor Author

@wyli I am using black locally as well. I always format my files with black before pushing them :-?

@wyli
Copy link
Contributor

wyli commented Apr 3, 2021

@Nic-Ma if I check the error of the check and I do what it asks I get

AttributeError: module 'ignite' has no attribute '__version__'

I installed the requirements based on requirements-dev.txt.

What should I do?

could you show the full traceback? I can look into it

@danieltudosiu
Copy link
Contributor Author

I checked and I have pytorch-ignite==0.4.4

Here it is:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/danieltudosiu/projects/MONAI/monai/__init__.py", line 43, in <module>
    load_submodules(sys.modules[__name__], False, exclude_pattern=excludes)
  File "/home/danieltudosiu/projects/MONAI/monai/utils/module.py", line 75, in load_submodules
    mod = import_module(name)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/danieltudosiu/projects/MONAI/monai/engines/__init__.py", line 12, in <module>
    from .evaluator import EnsembleEvaluator, Evaluator, SupervisedEvaluator
  File "/home/danieltudosiu/projects/MONAI/monai/engines/evaluator.py", line 17, in <module>
    from monai.engines.utils import IterationEvents, default_prepare_batch
  File "/home/danieltudosiu/projects/MONAI/monai/engines/utils.py", line 22, in <module>
    EventEnum, _ = optional_import("ignite.engine", "0.4.4", exact_version, "EventEnum")
  File "/home/danieltudosiu/projects/MONAI/monai/utils/module.py", line 201, in optional_import
    if not version_args and version_checker(pkg, f"{version}"):
  File "/home/danieltudosiu/projects/MONAI/monai/utils/module.py", line 109, in exact_version
    return bool(the_module.__version__ == version_str)
AttributeError: module 'ignite' has no attribute '__version__'

@wyli
Copy link
Contributor

wyli commented Apr 3, 2021

perhaps try pip uninstall ignite :)

@danieltudosiu
Copy link
Contributor Author

Why? What's the logics? Isn't pytorch-ignite an optional dependency of MONAI?

If I run "pip list | grep ignite" I get:

pytorch-ignite                0.4.4

Isn't this supposed to be what's required for us to develop by using Ignite infrastructure?

@wyli
Copy link
Contributor

wyli commented Apr 3, 2021

thanks @danieltudosiu

Why? What's the logics? Isn't pytorch-ignite an optional dependency of MONAI?

If I run "pip list | grep ignite" I get:

pytorch-ignite                0.4.4

Isn't this supposed to be what's required for us to develop by using Ignite infrastructure?

there's another package named ignite https://pypi.org/project/ignite the folders can be messed up...

@danieltudosiu
Copy link
Contributor Author

What else can it be? Since the checks are passing it means it is a local issue, not a MONAI one.

@Nic-Ma Nic-Ma enabled auto-merge (squash) April 4, 2021 01:04
@Nic-Ma Nic-Ma merged commit 348cbe8 into Project-MONAI:master Apr 4, 2021
@danieltudosiu danieltudosiu deleted the 1891_strict_false branch April 4, 2021 06:47
@vfdev-5
Copy link
Member

vfdev-5 commented Apr 4, 2021

What else can it be? Since the checks are passing it means it is a local issue, not a MONAI one.

@danieltudosiu it could be also probably explaned by #1930 where get_package_version before that PR removed the package from sys modules and thus there were a similar error while importing modules.

@danieltudosiu
Copy link
Contributor Author

@vfdev-5 Thanks for pointing it to me. Will pull the latest commit from MONAI.

nsrivathsa pushed a commit to nsrivathsa/MONAI that referenced this pull request Apr 12, 2021
* Enabled partial checkpoint loading

Allowing partial loading of a model via strict=False.

Signed-off-by: Petru-Daniel Tudosiu <[email protected]>

* [MONAI] python code formatting

Signed-off-by: monai-bot <[email protected]>

* [DLMED] simplify strict arg

Signed-off-by: Nic Ma <[email protected]>

Co-authored-by: monai-bot <[email protected]>
Co-authored-by: Nic Ma <[email protected]>
Signed-off-by: Neha Srivathsa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading models with strict=False
5 participants