Skip to content

fix: update Dockerfile and requirements-dev.txt for MONAI 1.6 tutorial compatibility#8912

Open
garciadias wants to merge 3 commits into
Project-MONAI:devfrom
garciadias:fix/monai_1_6_release_notebooks
Open

fix: update Dockerfile and requirements-dev.txt for MONAI 1.6 tutorial compatibility#8912
garciadias wants to merge 3 commits into
Project-MONAI:devfrom
garciadias:fix/monai_1_6_release_notebooks

Conversation

@garciadias

Copy link
Copy Markdown
Collaborator

Summary

  • Rebase Docker image from nvcr.io/nvidia/pytorch:24.10-py3 to 25.03-py3 to support RTX 5090 (Blackwell, SM_120/CUDA 12.8); remove the now-obsolete torch.patch ONNX revert which was specific to 24.10
  • Pin mlflow<3.0 — mlflow 3.x is broken on Python 3.12 due to a relative import in mlflow.utils.uv_utils (from .. import zipp fails at top-level scope); this caused 4 tutorial notebooks to fail in our CI run
  • Pin transformers<5.0 — transformers 5.x references torch.float8_e8m0fnu which does not exist in the nv25.03 build of PyTorch 2.7; this caused the HuggingFace tutorial to fail
  • Add aim and lightning>=2.0 as declared dependencies in requirements-dev.txt (were previously undeclared but required by tutorial notebooks)
  • Rebuild the NVIDIA pip constraint file to retain numpy==1.26.4 (nv25.03 PyTorch compiled against NumPy 1.x) and add setuptools<71 (newer setuptools dropped pkg_resources needed by legacy setup.py in git-sourced packages like MetricsReloaded and segment-anything)
  • Remove python_version <= '3.10' caps from cucim, onnxruntime, and transformers — these restrictions were keeping packages out of the Python 3.12 image unnecessarily
  • Install papermill, jupytext, autopep8, autoflake, and ipywidgets directly in the Dockerfile so the tutorial runner is self-contained

Context

These changes were identified by running the full MONAI tutorial test suite in a fresh Docker build against a MONAI 1.6 dev branch and comparing results with a native conda reference run (Eric's run, eccefc57). The rerun with stderr captured (runner_output_our_only.logs) confirmed the specific error for each notebook group.

Type of change

  • Bug fix
  • Feature
  • Hotfix
  • Spike / exploration
  • Documentation
  • Refactor

Test plan

  • Rebuild Docker image with docker build -t monai_1_6:latest .
  • Re-run bash run_our_only.sh 2>&1 | tee runner_output_v2.logs inside the container
  • Verify mlflow notebooks pass (R1: 4 notebooks)
  • Verify hugging_face/hugging_face_pipeline_for_monai.ipynb passes (R3)
  • Verify experiment_management/spleen_segmentation_aim.ipynb passes (R6)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7eaf21d3-4980-44f4-a281-8adaa8dda1f1

📥 Commits

Reviewing files that changed from the base of the PR and between bcb47e2 and 6ed7e10.

📒 Files selected for processing (1)
  • requirements-dev.txt

📝 Walkthrough

Walkthrough

Rewrites the image pip constraint file to keep the existing numpy pin and add setuptools<71, updates requirements-dev.txt with setuptools<71, tighter transformers and mlflow ranges, and new dev deps (aim on Linux, lightning>=2.0). Extends the Docker pip install step to install requirements-dev plus papermill, jupytext, autopep8, autoflake, and ipywidgets.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly summarizes the main changes: updating Dockerfile and requirements for MONAI 1.6 tutorial compatibility.
Description check ✅ Passed Description covers all template sections with detailed context, but test plan items are unchecked and remain pending execution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Around line 44-46: The Dockerfile currently re-specifies mlflow and
transformers in the extra pip install line, creating a conflicting second source
of truth; remove the "mlflow<3.0" and "transformers<5.0" entries from the python
-m pip install line that also installs
papermill/jupytext/autopep8/autoflake/ipywidgets so that mlflow and transformers
are only resolved from requirements-dev.txt (which pins >=2.12.2,<3.0 and
>=4.41.0,<5.0 respectively); keep the separate install for the other tools
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1a02d9ae-23fb-489b-b718-130352617025

📥 Commits

Reviewing files that changed from the base of the PR and between eccefc5 and 9a5bfeb.

📒 Files selected for processing (2)
  • Dockerfile
  • requirements-dev.txt

Comment thread Dockerfile Outdated
…l compatibility

Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>

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.
@garciadias garciadias force-pushed the fix/monai_1_6_release_notebooks branch from 9a5bfeb to a6c8f3e Compare June 11, 2026 13:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
Dockerfile (1)

30-30: 💤 Low value

Update version reference in comment.

If the base image is corrected to 25.03-py3 (per line 14 review comment), update this comment to reference "PyTorch nv25.03" instead of "nv25.12" for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` at line 30, Update the inline comment that mentions the PyTorch
build to match the base image change: replace the "nv25.12" reference with
"nv25.03" in the Dockerfile comment that currently reads about keeping the
numpy==1.26.4 pin so it consistently references "PyTorch nv25.03".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Line 32: The comment "remove jupytext/isort pins" is misleading because the
script currently overwrites /etc/pip/constraint.txt with only numpy and
setuptools constraints (removing everything implicitly) — either update the
comment to accurately state that the constraints file is being replaced, or
change the implementation to perform a selective removal of only jupytext and
isort pins (e.g., edit /etc/pip/constraint.txt in-place by filtering out lines
matching jupytext and isort) so the behavior matches the comment; reference the
Dockerfile comment "remove jupytext/isort pins" and the code path that writes
/etc/pip/constraint.txt.
- Line 14: Update the PYTORCH_IMAGE ARG value from
nvcr.io/nvidia/pytorch:25.12-py3 to nvcr.io/nvidia/pytorch:25.03-py3 to match
the PR target; adjust the constraint-file handling so the grep/sed pipeline that
looks for '^numpy==' in /etc/pip/constraint.txt does not cause a failing build
when no match exists (make the grep tolerant or fallback instead of aborting);
and change the RUN step that currently rewrites /etc/pip/constraint.txt to only
the numpy pin to instead selectively remove pins for jupytext and isort while
preserving other constraints (including keeping setuptools<71 if present).
Ensure you update the commands referencing "grep '^numpy=='", the ARG
PYTORCH_IMAGE, and the RUN that claims to "remove jupytext/isort pins" (so
behavior matches the comment).
- Line 33: The RUN step that extracts numpy constraints using grep can fail the
Docker build when there are no matches; modify the command that writes
/tmp/new_constraints.txt from /etc/pip/constraint.txt (the current grep
'^numpy==' invocation) to tolerate no matches (e.g., append "|| true" or use a
grep option that returns 0) so the step never exits non‑zero, then ensure the
subsequent operations still overwrite the original constraint file and append
"setuptools<71" as intended; update the surrounding comment to accurately state
that this step overwrites the constraint file with any numpy== lines (if
present) and then appends setuptools<71.

---

Nitpick comments:
In `@Dockerfile`:
- Line 30: Update the inline comment that mentions the PyTorch build to match
the base image change: replace the "nv25.12" reference with "nv25.03" in the
Dockerfile comment that currently reads about keeping the numpy==1.26.4 pin so
it consistently references "PyTorch nv25.03".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ea9ecbc0-57b9-4b2e-bc72-0fbecc67a32a

📥 Commits

Reviewing files that changed from the base of the PR and between 9a5bfeb and a6c8f3e.

📒 Files selected for processing (2)
  • Dockerfile
  • requirements-dev.txt
💤 Files with no reviewable changes (1)
  • requirements-dev.txt

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 3

🧹 Nitpick comments (1)
Dockerfile (1)

30-30: 💤 Low value

Update version reference in comment.

If the base image is corrected to 25.03-py3 (per line 14 review comment), update this comment to reference "PyTorch nv25.03" instead of "nv25.12" for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` at line 30, Update the inline comment that mentions the PyTorch
build to match the base image change: replace the "nv25.12" reference with
"nv25.03" in the Dockerfile comment that currently reads about keeping the
numpy==1.26.4 pin so it consistently references "PyTorch nv25.03".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Dockerfile`:
- Line 32: The comment "remove jupytext/isort pins" is misleading because the
script currently overwrites /etc/pip/constraint.txt with only numpy and
setuptools constraints (removing everything implicitly) — either update the
comment to accurately state that the constraints file is being replaced, or
change the implementation to perform a selective removal of only jupytext and
isort pins (e.g., edit /etc/pip/constraint.txt in-place by filtering out lines
matching jupytext and isort) so the behavior matches the comment; reference the
Dockerfile comment "remove jupytext/isort pins" and the code path that writes
/etc/pip/constraint.txt.
- Line 14: Update the PYTORCH_IMAGE ARG value from
nvcr.io/nvidia/pytorch:25.12-py3 to nvcr.io/nvidia/pytorch:25.03-py3 to match
the PR target; adjust the constraint-file handling so the grep/sed pipeline that
looks for '^numpy==' in /etc/pip/constraint.txt does not cause a failing build
when no match exists (make the grep tolerant or fallback instead of aborting);
and change the RUN step that currently rewrites /etc/pip/constraint.txt to only
the numpy pin to instead selectively remove pins for jupytext and isort while
preserving other constraints (including keeping setuptools<71 if present).
Ensure you update the commands referencing "grep '^numpy=='", the ARG
PYTORCH_IMAGE, and the RUN that claims to "remove jupytext/isort pins" (so
behavior matches the comment).
- Line 33: The RUN step that extracts numpy constraints using grep can fail the
Docker build when there are no matches; modify the command that writes
/tmp/new_constraints.txt from /etc/pip/constraint.txt (the current grep
'^numpy==' invocation) to tolerate no matches (e.g., append "|| true" or use a
grep option that returns 0) so the step never exits non‑zero, then ensure the
subsequent operations still overwrite the original constraint file and append
"setuptools<71" as intended; update the surrounding comment to accurately state
that this step overwrites the constraint file with any numpy== lines (if
present) and then appends setuptools<71.

---

Nitpick comments:
In `@Dockerfile`:
- Line 30: Update the inline comment that mentions the PyTorch build to match
the base image change: replace the "nv25.12" reference with "nv25.03" in the
Dockerfile comment that currently reads about keeping the numpy==1.26.4 pin so
it consistently references "PyTorch nv25.03".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ea9ecbc0-57b9-4b2e-bc72-0fbecc67a32a

📥 Commits

Reviewing files that changed from the base of the PR and between 9a5bfeb and a6c8f3e.

📒 Files selected for processing (2)
  • Dockerfile
  • requirements-dev.txt
💤 Files with no reviewable changes (1)
  • requirements-dev.txt
🛑 Comments failed to post (3)
Dockerfile (3)

14-14: ⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check NVIDIA NGC catalog for PyTorch 25.03 and 25.12 availability

echo "Checking NVIDIA PyTorch container tags for 25.03 and 25.12..."

# Query NGC API for available PyTorch tags
curl -s 'https://catalog.ngc.nvidia.com/api/resources/versions?orgName=nvidia&teamName=pytorch&name=pytorch&pageSize=100' \
  | jq -r '.results[].name' \
  | grep -E '^25\.(03|12)-py3$' || echo "No matching tags found"

Repository: Project-MONAI/MONAI

Length of output: 299


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show Dockerfile with line numbers around the claimed sections
echo "=== Dockerfile (with line numbers, full file if <=200 lines) ==="
wc -l Dockerfile
if [ "$(wc -l Dockerfile | awk '{print $1}')" -le 200 ]; then
  cat -n Dockerfile
else
  nl -ba Dockerfile | sed -n '1,120p'
  echo "..."
  nl -ba Dockerfile | sed -n '120,240p'
fi

# Find any repo references to the two PyTorch image tags
echo
echo "=== References to 25.03-py3 ==="
rg -n --hidden --glob '!.git/*' '25\.03-py3' . || true

echo
echo "=== References to 25.12-py3 ==="
rg -n --hidden --glob '!.git/*' '25\.12-py3' . || true

# Also search for the constraint-rewrite comment / claims (best-effort)
echo
echo "=== References to constraint.txt modifications ==="
rg -n --hidden --glob '!.git/*' 'constraint\.txt' Dockerfile . || true

echo
echo "=== References to jupytext/isort pins mention ==="
rg -n --hidden --glob '!.git/*' 'jupytext|isort' Dockerfile . || true

Repository: Project-MONAI/MONAI

Length of output: 6956


Align PYTORCH_IMAGE tag with PR target; harden constraint rewrite.

  • Dockerfile line 14 sets ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:25.12-py3, but the PR objectives/scope state nvcr.io/nvidia/pytorch:25.03-py3 (version mismatch).
  • Dockerfile lines 33-35: grep '^numpy==' /etc/pip/constraint.txt ... && ... cp ... will fail the build if the constraint file doesn’t contain a ^numpy==... line.
  • Dockerfile line 32 claims to “remove jupytext/isort pins”, but the RUN step actually rewrites the constraint file to only keep the extracted NumPy pin (plus setuptools<71), not selectively removing just jupytext/isort.
🔧 Proposed fix
-ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:25.12-py3
+ARG PYTORCH_IMAGE=nvcr.io/nvidia/pytorch:25.03-py3
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` at line 14, Update the PYTORCH_IMAGE ARG value from
nvcr.io/nvidia/pytorch:25.12-py3 to nvcr.io/nvidia/pytorch:25.03-py3 to match
the PR target; adjust the constraint-file handling so the grep/sed pipeline that
looks for '^numpy==' in /etc/pip/constraint.txt does not cause a failing build
when no match exists (make the grep tolerant or fallback instead of aborting);
and change the RUN step that currently rewrites /etc/pip/constraint.txt to only
the numpy pin to instead selectively remove pins for jupytext and isort while
preserving other constraints (including keeping setuptools<71 if present).
Ensure you update the commands referencing "grep '^numpy=='", the ARG
PYTORCH_IMAGE, and the RUN that claims to "remove jupytext/isort pins" (so
behavior matches the comment).

32-32: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Comment claims to "remove jupytext/isort pins" but code replaces entire file.

Line 32 states the script "remove[s] jupytext/isort pins", but lines 33-35 actually overwrite /etc/pip/constraint.txt with only the numpy and setuptools constraints. The removal is implicit (by not copying other constraints), not selective.

📝 Proposed clarification
-#   - remove jupytext/isort pins so the tutorial runner can install its required versions
+#   - discard all other constraints (including jupytext/isort) so the tutorial runner can install required versions
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` at line 32, The comment "remove jupytext/isort pins" is
misleading because the script currently overwrites /etc/pip/constraint.txt with
only numpy and setuptools constraints (removing everything implicitly) — either
update the comment to accurately state that the constraints file is being
replaced, or change the implementation to perform a selective removal of only
jupytext and isort pins (e.g., edit /etc/pip/constraint.txt in-place by
filtering out lines matching jupytext and isort) so the behavior matches the
comment; reference the Dockerfile comment "remove jupytext/isort pins" and the
code path that writes /etc/pip/constraint.txt.

33-33: ⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check if NVIDIA PyTorch 25.12-py3 base image has numpy constraint

echo "Attempting to pull base image and inspect /etc/pip/constraint.txt..."

docker pull nvcr.io/nvidia/pytorch:25.12-py3 2>&1 | head -20

if docker image inspect nvcr.io/nvidia/pytorch:25.12-py3 >/dev/null 2>&1; then
  echo -e "\n=== Contents of /etc/pip/constraint.txt ==="
  docker run --rm nvcr.io/nvidia/pytorch:25.12-py3 cat /etc/pip/constraint.txt 2>/dev/null || echo "File not found"
  
  echo -e "\n=== Lines starting with numpy== ==="
  docker run --rm nvcr.io/nvidia/pytorch:25.12-py3 grep '^numpy==' /etc/pip/constraint.txt 2>/dev/null || echo "No numpy constraint found"
else
  echo "Image not available locally or remotely"
fi

Repository: Project-MONAI/MONAI

Length of output: 217


Make the numpy-constraint rewrite resilient to missing matches

grep '^numpy==' /etc/pip/constraint.txt exits non-zero when there’s no numpy==... line, so the chained RUN will fail the Docker build. Also align the surrounding comment with the actual behavior: the step overwrites the constraint file (keeping only numpy matches) and then appends setuptools<71.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile` at line 33, The RUN step that extracts numpy constraints using
grep can fail the Docker build when there are no matches; modify the command
that writes /tmp/new_constraints.txt from /etc/pip/constraint.txt (the current
grep '^numpy==' invocation) to tolerate no matches (e.g., append "|| true" or
use a grep option that returns 0) so the step never exits non‑zero, then ensure
the subsequent operations still overwrite the original constraint file and
append "setuptools<71" as intended; update the surrounding comment to accurately
state that this step overwrites the constraint file with any numpy== lines (if
present) and then appends setuptools<71.

…mpatibility

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 <rafaelagd@gmail.com>
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 <rafaelagd@gmail.com>
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.

1 participant