From a6c8f3eef566adcb6eff6856bf245fc2a21228be Mon Sep 17 00:00:00 2001 From: "R. Garcia-Dias" Date: Thu, 11 Jun 2026 08:32:24 +0100 Subject: [PATCH 1/4] fix: update Dockerfile and requirements-dev.txt for MONAI 1.6 tutorial compatibility Signed-off-by: R. Garcia-Dias Base image updated to nvcr.io/nvidia/pytorch:25.12-py3 (aligned with upstream dev). Pin mlflow<3.0 (3.x broken on Python 3.12) and transformers<5.0 (5.x references torch.float8_e8m0fnu absent in older PyTorch builds). Add aim and lightning>=2.0 as declared dependencies. Remove Python 3.10 version caps from cucim and onnxruntime. Rebuild pip constraint file to keep numpy==1.26.4 and add setuptools<71. Add papermill/jupytext/autopep8/autoflake/ipywidgets for tutorial runner. --- Dockerfile | 11 ++++++++++- requirements-dev.txt | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e9f005e75e..55b093c7ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,12 +26,21 @@ RUN if [[ $(uname -m) =~ "aarch64" ]]; then \ WORKDIR /opt/monai +# Patch NVIDIA's pip constraint file: +# - keep numpy==1.26.4 pin (PyTorch nv25.12 was compiled against NumPy 1.x) +# - add setuptools<71 (newer setuptools removed pkg_resources needed by legacy setup.py) +# - remove jupytext/isort pins so the tutorial runner can install its required versions +RUN grep '^numpy==' /etc/pip/constraint.txt > /tmp/new_constraints.txt \ + && printf 'setuptools<71\n' >> /tmp/new_constraints.txt \ + && cp /tmp/new_constraints.txt /etc/pip/constraint.txt + # install full deps COPY requirements.txt requirements-min.txt requirements-dev.txt /tmp/ RUN cp /tmp/requirements.txt /tmp/req.bak \ && awk '!/torch/' /tmp/requirements.txt > /tmp/tmp && mv /tmp/tmp /tmp/requirements.txt \ && python -m pip install --upgrade --no-cache-dir --no-build-isolation pip wheel wheel-stub \ - && python -m pip install --no-cache-dir --no-build-isolation -r /tmp/requirements-dev.txt + && python -m pip install --no-cache-dir --no-build-isolation -r /tmp/requirements-dev.txt \ + && python -m pip install --no-cache-dir --no-build-isolation papermill jupytext autopep8 autoflake ipywidgets # compile ext and remove temp files # TODO: remark for issue [revise the dockerfile #1276](https://github.com/Project-MONAI/MONAI/issues/1276) diff --git a/requirements-dev.txt b/requirements-dev.txt index 08fcdc2b0e..4524e3ddf6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -33,9 +33,11 @@ tifffile; platform_system == "Linux" or platform_system == "Darwin" pandas requests einops -transformers>=4.53.0 -mlflow>=2.12.2,<3.13 +transformers>=4.53.0, <5.0 # 5.x references torch.float8_e8m0fnu absent in older PyTorch builds +mlflow>=2.12.2, <3.0 # 3.x broken on Python 3.12 (relative import in mlflow.utils.uv_utils) clearml>=1.10.0rc0 +aim # experiment tracking backend for spleen_segmentation_aim tutorial +lightning>=2.0 # PyTorch Lightning for lightning-based training tutorials matplotlib>=3.6.3 tensorboardX types-PyYAML From bcb47e20ac0b476a4c4615a1a504a3dddfeb591b Mon Sep 17 00:00:00 2001 From: "R. Garcia-Dias" Date: Thu, 11 Jun 2026 14:16:05 +0100 Subject: [PATCH 2/4] fix: pin setuptools<71 in requirements-dev.txt for MetricsReloaded compatibility MetricsReloaded's setup.py imports pkg_resources, which was removed from setuptools>=71. The Dockerfile already constrains this via /etc/pip/constraint.txt, but CI runners (GitHub Actions) have no such constraint and fail with ModuleNotFoundError: No module named 'pkg_resources' during MetricsReloaded build. Signed-off-by: R. Garcia-Dias --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 4524e3ddf6..47dd0f99d7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -18,6 +18,7 @@ black>=26.3.1 isort>=5.1, <6, !=6.0.0 ruff>=0.14.11,<0.15 pybind11 +setuptools<71 # pkg_resources removed in setuptools>=71; needed by MetricsReloaded setup.py types-setuptools mypy>=1.5.0, <1.12.0 ninja From 6ed7e10dae8570d39eae4d25e1a00d0ab155645c Mon Sep 17 00:00:00 2001 From: "R. Garcia-Dias" Date: Thu, 11 Jun 2026 14:19:44 +0100 Subject: [PATCH 3/4] fix: restrict aim to Linux in requirements-dev.txt aim's build requires aimrocks (C extension with no Windows wheels), causing metadata-generation-failed on Windows CI runners. aim is only used by the spleen_segmentation_aim tutorial which requires a Linux/GPU environment anyway. Signed-off-by: R. Garcia-Dias --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 47dd0f99d7..81fba00f6a 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -37,7 +37,7 @@ einops transformers>=4.53.0, <5.0 # 5.x references torch.float8_e8m0fnu absent in older PyTorch builds mlflow>=2.12.2, <3.0 # 3.x broken on Python 3.12 (relative import in mlflow.utils.uv_utils) clearml>=1.10.0rc0 -aim # experiment tracking backend for spleen_segmentation_aim tutorial +aim; platform_system == "Linux" # experiment tracking backend for spleen_segmentation_aim tutorial lightning>=2.0 # PyTorch Lightning for lightning-based training tutorials matplotlib>=3.6.3 tensorboardX From aa960075e4f374776def4276d71b1763f55b1e8a Mon Sep 17 00:00:00 2001 From: "R. Garcia-Dias" Date: Tue, 16 Jun 2026 09:00:57 +0100 Subject: [PATCH 4/4] fix: pin urllib3>=2 in pip constraints; tolerate empty constraint.txt Two Dockerfile changes for nvcr.io/nvidia/pytorch:25.12-py3 compatibility: 1. Tolerate base images where /etc/pip/constraint.txt is empty (nv25.12 ships an empty file; nv25.03 pinned numpy==1.26.4 there). Use `(grep '^numpy' ... || true)` instead of bare grep so the RUN step does not exit 1 when no numpy line is present. 2. Add urllib3>=2 to the pip constraint file. Without this, any notebook cell that runs `!pip install legacy-pkg` (e.g. bentoml==0.13.1) can silently downgrade urllib3 to 1.x, which breaks requests, and therefore huggingface_hub, gdown, transformers, mlflow, and clearml for every notebook that runs afterwards in the same container session. Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 55b093c7ba..064491f0d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,11 +27,15 @@ RUN if [[ $(uname -m) =~ "aarch64" ]]; then \ WORKDIR /opt/monai # Patch NVIDIA's pip constraint file: -# - keep numpy==1.26.4 pin (PyTorch nv25.12 was compiled against NumPy 1.x) +# - keep the base image's numpy pin if it has one (nv25.03 pins numpy==1.26.4 as its +# torch was compiled against NumPy 1.x; nv25.12 ships an empty constraint.txt) # - add setuptools<71 (newer setuptools removed pkg_resources needed by legacy setup.py) +# - pin urllib3>=2 so that notebook cells doing !pip install legacy packages (e.g. +# bentoml==0.13.1) cannot downgrade urllib3 to 1.x, which would break requests, +# huggingface_hub, gdown, transformers, mlflow, etc. for every subsequent notebook # - remove jupytext/isort pins so the tutorial runner can install its required versions -RUN grep '^numpy==' /etc/pip/constraint.txt > /tmp/new_constraints.txt \ - && printf 'setuptools<71\n' >> /tmp/new_constraints.txt \ +RUN (grep '^numpy' /etc/pip/constraint.txt || true) > /tmp/new_constraints.txt \ + && printf 'setuptools<71\nurllib3>=2\n' >> /tmp/new_constraints.txt \ && cp /tmp/new_constraints.txt /etc/pip/constraint.txt # install full deps