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

Updating to match Numpy 2.0 requirements #7857

Merged
merged 16 commits into from
Aug 19, 2024

Conversation

ericspod
Copy link
Member

@ericspod ericspod commented Jun 17, 2024

Fixes #7856.

Description

This introduces changes to meet Numpy 2.0 requirements. MONAI itself is compatible with Numpy 2.0 however some dependencies are not such as older versions of Pytorch. This PR adjusts the MAX_SEED value to be compatible with Numpy 2.0 behaviour changes, uses the ptp function, and some other minor tweaks. The versions for dependencies are also fixed to exclude Numpy 2.0.

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 --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

@ericspod ericspod mentioned this pull request Jun 17, 2024
7 tasks
Signed-off-by: Eric Kerfoot <[email protected]>
@ericspod ericspod changed the title Updating use of MAX_SEED to match Numpy 2.0 requirements Updating to match Numpy 2.0 requirements Jun 17, 2024
@ericspod ericspod marked this pull request as draft June 17, 2024 15:51
@Nic-Ma
Copy link
Contributor

Nic-Ma commented Aug 12, 2024

Hi @ericspod ,

Thanks for your quick update for Numpy 2.0.
May I know whether you found any test failures due to 3rd party dependency can't support Numpy 2.0 so far?

Thanks in advance.

@ericspod
Copy link
Member Author

ericspod commented Aug 16, 2024

These appear to be NOT compatible with Numpy2:

  • Pytorch<2.3
  • Pytorch 2.4.0+cpu on Windows?
  • Pyarrow
  • ClearML when using Pyarrow

I, Eric Kerfoot <[email protected]>, hereby add my Signed-off-by to this commit: 5c0b5f6

Signed-off-by: Eric Kerfoot <[email protected]>
@ericspod ericspod marked this pull request as ready for review August 16, 2024 17:16
@ericspod
Copy link
Member Author

@KumoLiu We'll leave the requirements excluding Numpy2 but otherwise updating the minimum version.

environment-dev.yml Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 19, 2024

/build

Copy link
Contributor

@KumoLiu KumoLiu left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, looks good to me.

@KumoLiu KumoLiu merged commit 3a6f620 into Project-MONAI:dev Aug 19, 2024
28 checks passed
rcremese pushed a commit to rcremese/MONAI that referenced this pull request Sep 2, 2024
Fixes Project-MONAI#7856. 

### Description

This introduces changes to meet Numpy 2.0 requirements. MONAI itself is
compatible with Numpy 2.0 however some dependencies are not such as
older versions of Pytorch. This PR adjusts the MAX_SEED value to be
compatible with Numpy 2.0 behaviour changes, uses the `ptp` function,
and some other minor tweaks. The versions for dependencies are also
fixed to exclude Numpy 2.0.

### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] 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 --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: Eric Kerfoot <[email protected]>
Co-authored-by: YunLiu <[email protected]>
@michael-camilleri
Copy link

Will Numpy 2 be supported soon? Especially as the dependency is due to older versions of pytorch/other libraries and not explicitly support within MONAI itself? is there a reason why MONAI does not drop older versions of pytorch?

@ericspod
Copy link
Member Author

Hi @michael-camilleri The dependency issue for us is that we do want to continue supporting older versions of Pytorch because many users may need older versions for compatibility or because their environment requires it. The problem that everyone has discovered is that their versions strings for Numpy would set a minimum requirement but not a max, so Numpy 2.0 with its incompatibility isn't excluded. Older versions of libraries are unlikely to be updated with support for Numpy 2.0, and we have no way of forcing Numpy 1.x when these are present. For the moment we've chosen to just restrict the version although MONAI itself should be compatible now with the changes made. I think it would work for you to try installing MONAI in an environment (venv or conda) and then installing Numpy 2.0 subsequently.

@michael-camilleri
Copy link

Thanks.
Indeed, that is what I did and seems to be working. Wondering if there is a way of supporting this versioning in the documentation... I did not realise that numpy had been downgraded until a colleague (who needed 2.0) came across some code errors.

@ericspod ericspod deleted the max_seed_fix branch November 27, 2024 14:53
@ericspod
Copy link
Member Author

I agree, we can improve the documentation and mention this issue with Numpy 2. Beyond that, we would need a way of directly controlling version resolution in pip to account for known incompatibilities, but this isn't currently possible and would rely on guessing which libraries have a 2.0 problem.

@michael-camilleri
Copy link

michael-camilleri commented Nov 27, 2024 via email

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.

Numpy 2.0 Behaviour Changes
4 participants