Project-MONAI / Project-MONAI/tutorials

nnunetv2 support for numpy >=2.0

Open
#1,986 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Jupyter Notebook
Stars
2.5k
Forks
803
Avg merge
6d 22h
Merged PRs (30d)
3

Description

[2025-05-01T13:49:17.542Z] + python -m tests.integration.test_integration_nnunetv2_runner

[2025-05-01T13:49:18.474Z] 

[2025-05-01T13:49:18.474Z] A module that was compiled using NumPy 1.x cannot be run in

[2025-05-01T13:49:18.474Z] NumPy 2.2.5 as it may crash. To support both 1.x and 2.x

[2025-05-01T13:49:18.474Z] versions of NumPy, modules must be compiled with NumPy 2.0.

[2025-05-01T13:49:18.474Z] Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

[2025-05-01T13:49:18.474Z] 

[2025-05-01T13:49:18.474Z] If you are a user of the module, the easiest solution will be to

[2025-05-01T13:49:18.474Z] downgrade to 'numpy<2' or try to upgrade the affected module.

[2025-05-01T13:49:18.474Z] We expect that some modules will need time to support NumPy 2.

[2025-05-01T13:49:18.474Z] 

[2025-05-01T13:49:18.474Z] Traceback (most recent call last):  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main

[2025-05-01T13:49:18.474Z]     return _run_code(code, main_globals, None,

[2025-05-01T13:49:18.474Z]   File "/usr/lib/python3.10/runpy.py", line 86, in _run_code

[2025-05-01T13:49:18.474Z]     exec(code, run_globals)

[2025-05-01T13:49:18.474Z]   File "/home/jenkins/agent/workspace/Monai-notebooks/MONAI/tests/integration/test_integration_nnunetv2_runner.py", line 21, in <module>

[2025-05-01T13:49:18.474Z]     from monai.apps.nnunet import nnUNetV2Runner

[2025-05-01T13:49:18.474Z]   File "/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/__init__.py", line 83, in <module>

[2025-05-01T13:49:18.474Z]     from .utils.module import load_submodules  # noqa: E402

[2025-05-01T13:49:18.474Z]   File "/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/utils/__init__.py", line 16, in <module>

[2025-05-01T13:49:18.474Z]     from .deprecate_utils import DeprecatedError, deprecated, deprecated_arg, deprecated_arg_default

[2025-05-01T13:49:18.474Z]   File "/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/utils/deprecate_utils.py", line 22, in <module>

[2025-05-01T13:49:18.474Z]     from monai.utils.module import version_leq

[2025-05-01T13:49:18.474Z]   File "/home/jenkins/agent/workspace/Monai-notebooks/MONAI/monai/utils/module.py", line 30, in <module>

[2025-05-01T13:49:18.474Z]     import torch

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/__init__.py", line 2479, in <module>

[2025-05-01T13:49:18.474Z]     from torch import (

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/export/__init__.py", line 64, in <module>

[2025-05-01T13:49:18.474Z]     from .dynamic_shapes import Constraint, Dim, dims, ShapesCollection

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/export/dynamic_shapes.py", line 22, in <module>

[2025-05-01T13:49:18.474Z]     from .exported_program import ExportedProgram

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/export/exported_program.py", line 27, in <module>

[2025-05-01T13:49:18.474Z]     from torch._higher_order_ops.utils import autograd_not_implemented

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/_higher_order_ops/__init__.py", line 1, in <module>

[2025-05-01T13:49:18.474Z]     from torch._higher_order_ops.cond import cond

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/_higher_order_ops/cond.py", line 6, in <module>

[2025-05-01T13:49:18.474Z]     import torch._subclasses.functional_tensor

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/functional_tensor.py", line 44, in <module>

[2025-05-01T13:49:18.474Z]     class FunctionalTensor(torch.Tensor):

[2025-05-01T13:49:18.474Z]   File "/usr/local/lib/python3.10/dist-packages/torch/_subclasses/functional_tensor.py", line 271, in FunctionalTensor

[2025-05-01T13:49:18.474Z]     cpu = _conversion_method_template(device=torch.device("cpu"))

[2025-05-01T13:49:18.474Z] /usr/local/lib/python3.10/dist-packages/torch/_subclasses/functional_tensor.py:271: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at /opt/pytorch/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.)

[2025-05-01T13:49:18.474Z]   cpu = _conversion_method_template(device=torch.device("cpu"))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running tests/integration/test_integration_nnunetv2_runner.py and inspect the import path shown in the traceback. Trace the NumPy compatibility failure through the nnUNetV2 integration setup; done means this integration test runs successfully with NumPy 2.x without the reported initialization warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python, pytorch
Domain
machine-learning, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.