Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
env:
# minimum supported version of Python
PYTHON_VER1: '3.10'
# force installation of CPU-only PyTorch
PIP_EXTRA_INDEX_URL: 'https://download.pytorch.org/whl/cpu'
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ env.PYTHON_VER1 }}
Expand All @@ -33,7 +35,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r docs/requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
python -m pip install .[all,testing]
- name: Make html
run: |
cd docs/
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/cicd_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install --no-build-isolation -r requirements-dev.txt
python -m pip install .[all,testing]
- name: Lint and type check
run: |
# clean up temporary files
Expand Down Expand Up @@ -144,9 +144,8 @@ jobs:
run: |
# min. requirements
python -m pip install torch==${{ matrix.pytorch-version }}
python -m pip install -r requirements-min.txt
python -m pip install -e .[testing]
python -m pip list
BUILD_MONAI=0 python setup.py develop # no compile of extensions
shell: bash
- if: matrix.os == 'linux-gpu-runner'
name: Print GPU Info
Expand Down Expand Up @@ -220,10 +219,8 @@ jobs:
- name: Install the complete dependencies
run: |
python -m pip install --user --upgrade pip wheel pybind11 # TODO: pybind11 added for macOS, may not be needed
cat "requirements-dev.txt"
python -m pip install --no-build-isolation -r requirements-dev.txt
python -m pip install -e .[all,testing]
python -m pip list
python -m pip install --no-build-isolation -e . # test no compile installation
shell: bash
- name: Run compiled (${{ runner.os }})
run: |
Expand Down Expand Up @@ -277,12 +274,12 @@ jobs:
run: |
python -m pip install --upgrade pip wheel
python -m pip install torch==${PYTORCH_VER1} torchvision==${TORCHVISION_VER1}
python -m pip install --no-build-isolation -r requirements-dev.txt
python -m pip install -e .
# nvsubquadratic runtime imports need only torch + einops + omegaconf; install
# the package itself without its core dependency tree (see job comment above).
python -m pip install omegaconf
python -m pip install --no-deps 'nvsubquadratic>=0.1.1'
python -m pip install -e .[all,hyena,testing]
# # nvsubquadratic runtime imports need only torch + einops + omegaconf; install
# # the package itself without its core dependency tree (see job comment above).
# python -m pip install omegaconf
# python -m pip install --no-deps 'nvsubquadratic>=0.1.1'
python -m pip install -e .[hyena]
Comment on lines +277 to +282

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Keep the Hyena dependency install --no-deps.

.[hyena] resolves nvsubquadratic and its Torch constraint, contradicting the job’s stated isolation strategy. Install .[all,testing], then explicitly install omegaconf and nvsubquadratic with --no-deps; remove the second editable install.

🤖 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 @.github/workflows/cicd_tests.yml around lines 277 - 282, Update the
dependency installation steps in the workflow to install only `.[all,testing]`,
then explicitly install `omegaconf` and `nvsubquadratic>=0.1.1` with
`--no-deps`. Remove the separate `python -m pip install -e .[hyena]` step and
keep the existing isolation strategy.

python -m pip list
shell: bash
- name: Run Hyena tests (CUDA-required cases skip cleanly)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ jobs:
rm -rf /opt/hostedtoolcache/{node,go,Ruby,Java*}
ls -al /opt/hostedtoolcache
rm -rf /usr/share/dotnet/
python -m pip install -U --no-build-isolation pip wheel wheel-stub
python -m pip install --no-build-isolation -r requirements-dev.txt
python -m pip install -U pip wheel wheel-stub
python -m pip install .[all,testing]
BUILD_MONAI=1 ./runtests.sh --build
- name: Perform CodeQL Analysis
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cron-ngc-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- name: Install dependencies
run: |
rm -rf /github/home/.cache/torch/hub/bundle/
python -m pip install --no-build-isolation --upgrade pip wheel wheel-stub
python -m pip install --no-build-isolation -r requirements-dev.txt
python -m pip install -U pip wheel wheel-stub
python -m pip install .[all,testing]
- name: Loading Bundles
run: |
# clean up temporary files
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
python -m pip install --upgrade pip wheel
python -m pip uninstall -y torch torchvision
python -m pip install ${{ matrix.pytorch }}
python -m pip install -r requirements-dev.txt
python -m pip install .[all,testing]
python -m pip list
- name: Run tests report coverage
env:
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
run: |
which python
python -m pip install --upgrade pip wheel
python -m pip install -r requirements-dev.txt
python -m pip install .[all,testing]
python -m pip list
- name: Run tests report coverage
env:
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
python -c $'import torch\na,b=torch.zeros(1,device="cuda:0"),torch.zeros(1,device="cuda:1");\nwhile True:print(a,b)' > /dev/null &
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"

python -m pip install -r requirements-dev.txt
python -m pip install .[all,testing]

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not install . from the artifact directory.

At this point $tmp_dir contains the sdist and tests, not pyproject.toml or setup.py, so this fails. Install "${name}[all,testing]" at the artifact-install step and remove this command and the obsolete requirements*.txt copy.

🤖 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 @.github/workflows/cron.yml at line 189, Update the artifact-install step in
the workflow to install the built package by its package name variable, using
the extras all and testing, instead of installing the current directory. Remove
the python -m pip install .[all,testing] command and the obsolete
requirements*.txt copy from this step.

PYTHONPATH="$tmp_dir":$PYTHONPATH BUILD_MONAI=1 python ./tests/runner.py -p 'test_((?!integration).)' # unit tests
if pgrep python; then pkill python; fi

Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
run: |
which python
python -m pip install --upgrade pip wheel
python -m pip install -r requirements-dev.txt
python -m pip install .[all,testing]

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.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow matching files =="
fd -a 'cron\.yml$|cron\.yaml$' .github/workflows 2>/dev/null || true

echo "== target lines =="
if [ -f .github/workflows/cron.yml ]; then
  nl -ba .github/workflows/cron.yml | sed -n '228,250p'
fi

echo "== pip install / setup.py occurrences =="
rg -n "pip install|setup\.py develop|\[all,testing\]|BUILD_MONAI" .github/workflows/cron.yml .github/workflows 2>/dev/null || true

echo "== repository references to install commands =="
rg -n "pip install.*\[all,testing\]|setup\.py develop|BUILD_MONAI|editable|develop" .github workflows setup.py pyproject.toml 2>/dev/null | head -120 || true

Repository: Project-MONAI/MONAI

Length of output: 292


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== target lines =="
awk 'NR>=228 && NR<=252 { printf "%s\t%s\n", NR, $0 }' .github/workflows/cron.yml

echo "== install-related occurrences in cron workflow =="
awk '
  /pip install|setup\.py develop|\[all,testing\]|BUILD_MONAI|develop|editable|editable_install/ {
    printf "%s\t%s\n", NR, $0
  }
' .github/workflows/cron.yml

echo "== repository installs mentioning all/testing/build_monai/develop =="
git grep -n "pip install.*\[all,testing\]\|setup\.py develop\|BUILD_MONAI\|\[all,testing\]\|\[testing\]" .github setup.py pyproject.toml README.md 2>/dev/null | head -200 || true

Repository: Project-MONAI/MONAI

Length of output: 7270


Finish the pip-only migration.

Line 243 still runs BUILD_MONAI=1 python setup.py develop. Replace both install commands with BUILD_MONAI=1 python -m pip install -e .[all,testing].

🤖 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 @.github/workflows/cron.yml at line 242, Update the dependency installation
steps in the workflow to complete the pip-only migration: replace both the
existing pip install and BUILD_MONAI setup.py develop commands with
BUILD_MONAI=1 python -m pip install -e .[all,testing].

BUILD_MONAI=1 python setup.py develop # install monai
nvidia-smi
export CUDA_VISIBLE_DEVICES=$(python -m tests.utils | tail -n 1)
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ jobs:
cat _version.py
mv _version.py monai/
# build "latest": remove flake package as it is not needed on hub.docker.com
sed -i '/flake/d' requirements-dev.txt
docker build -t projectmonai/monai:latest -f Dockerfile .
# distribute as always w/ tag "latest" to hub.docker.com
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ jobs:
pip uninstall -y monai
pip uninstall -y monai-weekly
pip uninstall -y monai-weekly
python -m pip install --upgrade torch torchvision torchaudio torchtext
python -m pip install -r requirements-dev.txt
python -m pip install .[all,testing]

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Use a Python 3.10+ integration image. Both jobs run nvcr.io/nvidia/pytorch:22.04-py3 (Python 3.8), while pyproject.toml requires Python >=3.10; pip will reject these installs.

  • .github/workflows/integration.yml#L40-L40: update the container to a Python 3.10+ image before installing extras.
  • .github/workflows/integration.yml#L115-L115: update the container to the same compatible Python version.
📍 Affects 1 file
  • .github/workflows/integration.yml#L40-L40 (this comment)
  • .github/workflows/integration.yml#L115-L115
🤖 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 @.github/workflows/integration.yml at line 40, Update the container image
used by both integration jobs in .github/workflows/integration.yml at lines
40-40 and 115-115 to the same image providing Python 3.10 or newer, before the
python -m pip install steps; no other workflow behavior needs to change.

rm -rf /github/home/.cache/torch/hub/mmars/
- name: Clean directory
run: |
Expand Down Expand Up @@ -113,8 +112,7 @@ jobs:
pip uninstall -y monai
pip uninstall -y monai-weekly
pip uninstall -y monai-weekly
python -m pip install --upgrade torch torchvision torchaudio torchtext
python -m pip install -r requirements-dev.txt
python -m pip install .[all,testing]
rm -rf /github/home/.cache/torch/hub/mmars/
- name: Clean directory
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonapp-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
rm -rf $(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")/ruamel*
rm -rf $(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")/llvmlite* #6377
python -m pip install ${{ matrix.pytorch }}
python -m pip install -r requirements-dev.txt
python -m pip install .[all,testing]
python -m pip list
- name: Run quick tests (GPU)
if: github.event.pull_request.merged != true
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pythonapp-hyena-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ jobs:
run: |
python -m pip install --upgrade pip wheel
python -c "import sys; assert sys.version_info >= (3, 10), f'Python >= 3.10 required for nvsubquadratic, got {sys.version}'"
python -m pip install -r requirements-dev.txt
python -m pip install -e .
python -m pip install -e .[all,testing]
# Install nvsubquadratic with --no-deps: the default torch_fft path needs only
# torch + einops + omegaconf, and nvsubquadratic pins torch>=2.10,<2.11 which can
# clash with the container's torch. To exercise the accelerated fused CUDA
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ jobs:
echo "unmatched version string, please check the tagging branch."
exit 1
fi
# remove flake package as it is not needed on hub.docker.com
sed -i '/flake/d' requirements-dev.txt
docker build -t projectmonai/monai:"$RELEASE_VERSION" -f Dockerfile .
# distribute with a tag to hub.docker.com
echo "${{ secrets.DOCKER_PW }}" | docker login -u projectmonai --password-stdin
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/weekly-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install --no-build-isolation -r requirements-dev.txt
python -m pip install -U pip wheel
python -m pip install .[all,testing]
- name: Lint and type check
run: |
# clean up temporary files
Expand Down
45 changes: 14 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ FROM ${PYTORCH_IMAGE}

LABEL maintainer="monai.contact@gmail.com"

ENV BUILD_MONAI=1

# TODO: remark for issue [revise the dockerfile](https://github.com/zarr-developers/numcodecs/issues/431)
RUN if [[ $(uname -m) =~ "aarch64" ]]; then \
export CFLAGS="-O3" && \
Expand All @@ -24,36 +26,6 @@ RUN if [[ $(uname -m) =~ "aarch64" ]]; then \
pip install numcodecs; \
fi

WORKDIR /opt/monai

# Patch NVIDIA's pip constraint file:
# - keep the base image's numpy pin if present (older images pin numpy==1.26.4 as
# their torch was compiled against NumPy 1.x; newer images may ship an empty file)
# - add setuptools<71 (setuptools>=71 removed pkg_resources, breaking MetricsReloaded)
# - pin urllib3>=2 to prevent inadvertent downgrades by pip-installing legacy packages
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
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

# compile ext and remove temp files
# TODO: remark for issue [revise the dockerfile #1276](https://github.com/Project-MONAI/MONAI/issues/1276)
# please specify exact files and folders to be copied -- else, basically always, the Docker build process cannot cache
# this or anything below it and always will build from at most here; one file change leads to no caching from here on...

COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py setup.cfg runtests.sh MANIFEST.in ./
COPY tests ./tests
COPY monai ./monai

RUN BUILD_MONAI=1 FORCE_CUDA=1 python setup.py develop \
&& rm -rf build __pycache__

# NGC Client
WORKDIR /opt/tools
ARG NGC_CLI_URI="https://ngc.nvidia.com/downloads/ngccli_linux.zip"
Expand All @@ -68,5 +40,16 @@ RUN apt-get update \
ENV PATH=${PATH}:/opt/tools
ENV POLYGRAPHY_AUTOINSTALL_DEPS=1


WORKDIR /opt/monai

# TODO: remark for issue [revise the dockerfile #1276](https://github.com/Project-MONAI/MONAI/issues/1276)
# please specify exact files and folders to be copied -- else, basically always, the Docker build process cannot cache
# this or anything below it and always will build from at most here; one file change leads to no caching from here on...
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py pyproject.toml runtests.sh MANIFEST.in ./
COPY tests ./tests
COPY monai ./monai

# Need to install build requirements explicitly so that no-build-isolation can be used. This needed to make pip build
# against the included version of PyTorch, rather than install a new version in the isolated environment.
RUN python monai/config/print_dependencies.py build-system | xargs pip install --no-cache-dir --no-build-isolation \
&& FORCE_CUDA=1 pip install --no-cache-dir --no-build-isolation -e .[all,testing]
18 changes: 7 additions & 11 deletions Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ RUN apt update && apt upgrade -y && \
wget https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb && \
dpkg -i cuda-keyring_1.1-1_all.deb && \
apt update && \
${APT_INSTALL} cuda-toolkit-12-9 && \
${APT_INSTALL} cuda-toolkit-13-3 && \
rm -rf /usr/lib/python*/EXTERNALLY-MANAGED /var/lib/apt/lists/* && \
python -m pip install --upgrade --no-cache-dir --no-build-isolation pip
python -m pip install --upgrade --no-cache-dir pip

# TODO: remark for issue [revise the dockerfile](https://github.com/zarr-developers/numcodecs/issues/431)
RUN if [[ $(uname -m) =~ "aarch64" ]]; then \
Expand All @@ -46,18 +46,14 @@ RUN wget -q ${NGC_CLI_URI} && unzip ngccli_linux.zip && chmod u+x ngc-cli/ngc &&

WORKDIR /opt/monai

# copy relevant parts of repo
COPY requirements.txt requirements-min.txt requirements-dev.txt versioneer.py setup.py setup.cfg pyproject.toml ./
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md MANIFEST.in runtests.sh ./
# TODO: remark for issue [revise the dockerfile #1276](https://github.com/Project-MONAI/MONAI/issues/1276)
# please specify exact files and folders to be copied -- else, basically always, the Docker build process cannot cache
# this or anything below it and always will build from at most here; one file change leads to no caching from here on...
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py pyproject.toml runtests.sh MANIFEST.in ./
COPY tests ./tests
COPY monai ./monai

# install full deps
RUN python -m pip install --no-cache-dir --no-build-isolation -U wheel wheel-stub
RUN python -m pip install --no-cache-dir --no-build-isolation "torch>=2.8.0,<2.11" -r requirements-dev.txt

# compile ext
RUN CUDA_HOME=/usr/local/cuda FORCE_CUDA=1 USE_COMPILED=1 BUILD_MONAI=1 python setup.py develop
RUN BUILD_MONAI=1 FORCE_CUDA=1 pip install --no-cache-dir -e .[all,testing]
Comment on lines +49 to +56

@coderabbitai coderabbitai Bot Jul 23, 2026

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Missing --no-build-isolation risks ABI-mismatched compiled extensions.

Unlike Dockerfile (which pre-installs build-system deps and uses --no-build-isolation), this editable install with BUILD_MONAI=1 uses pip's default build isolation. Per this PR's own new warning in docs/source/installation.md, build isolation may resolve a different PyTorch than the one that ends up installed at runtime, producing a compiled extension that's ABI-incompatible and won't load. Apply the same pattern as Dockerfile.

🔧 Proposed fix mirroring Dockerfile's approach
-RUN BUILD_MONAI=1 FORCE_CUDA=1 pip install --no-cache-dir -e .[all,testing]
+RUN python monai/config/print_dependencies.py build-system | xargs pip install --no-cache-dir --no-build-isolation \
+  && BUILD_MONAI=1 FORCE_CUDA=1 pip install --no-cache-dir --no-build-isolation -e .[all,testing]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# TODO: remark for issue [revise the dockerfile #1276](https://github.com/Project-MONAI/MONAI/issues/1276)
# please specify exact files and folders to be copied -- else, basically always, the Docker build process cannot cache
# this or anything below it and always will build from at most here; one file change leads to no caching from here on...
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py pyproject.toml runtests.sh MANIFEST.in ./
COPY tests ./tests
COPY monai ./monai
# install full deps
RUN python -m pip install --no-cache-dir --no-build-isolation -U wheel wheel-stub
RUN python -m pip install --no-cache-dir --no-build-isolation "torch>=2.8.0,<2.11" -r requirements-dev.txt
# compile ext
RUN CUDA_HOME=/usr/local/cuda FORCE_CUDA=1 USE_COMPILED=1 BUILD_MONAI=1 python setup.py develop
RUN BUILD_MONAI=1 FORCE_CUDA=1 pip install --no-cache-dir -e .[all,testing]
# TODO: remark for issue [revise the dockerfile `#1276`](https://github.com/Project-MONAI/MONAI/issues/1276)
# please specify exact files and folders to be copied -- else, basically always, the Docker build process cannot cache
# this or anything below it and always will build from at most here; one file change leads to no caching from here on...
COPY LICENSE CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md versioneer.py setup.py pyproject.toml runtests.sh MANIFEST.in ./
COPY tests ./tests
COPY monai ./monai
RUN python monai/config/print_dependencies.py build-system | xargs pip install --no-cache-dir --no-build-isolation \
&& BUILD_MONAI=1 FORCE_CUDA=1 pip install --no-cache-dir --no-build-isolation -e .[all,testing]
🤖 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.slim` around lines 49 - 56, Update the editable install command
after the BUILD_MONAI and FORCE_CUDA environment settings to include pip’s
--no-build-isolation option, matching the established Dockerfile installation
pattern and ensuring extensions build against the preinstalled runtime
dependencies.

@ericspod ericspod Jul 25, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@coderabbitai This should use the same PyTorch version for the isolated environment as the install environment as setuptools is in the "dependencies" explicitly. This was the library that causes some of the PyTorch version mismatches. Is there any way of forcing pip to use the same versions of dependencies in the isolated environment as it would install into the target environment without discarding build isolation?

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.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '=== pyproject build-system and dependency-related sections ==='
awk '
  /^\[build-system\]$/ {show=1}
  /^\[/ && $0 != "[build-system]" && show {exit}
  show {print}
' pyproject.toml

printf '%s\n' '=== dependency/constraint file names ==='
fd -HI -t f '(^|/)(requirements.*|constraints.*|.*\.lock)$' . | sort

printf '%s\n' '=== PyTorch and build-isolation references in packaging files ==='
rg -n -i -C2 '(torch|build-system|build-isolation|setuptools)' \
  pyproject.toml setup.py setup.cfg requirements*.txt 2>/dev/null || true

Length of output: 7706


🤖 web_search executed:

pip documentation --build-constraint option isolated build environment constraint file target environment --constraint

Length of output: 5187


@ericspod Yes—keep isolation and use a shared exact constraints/lock file for both resolver runs:

RUN BUILD_MONAI=1 FORCE_CUDA=1 pip install --no-cache-dir \
    --constraint constraints.txt \
    --build-constraint constraints.txt \
    -e .[all,testing]

constraints.txt must pin PyTorch exactly, e.g. torch==2.x.y (and any related packages/index choices required for the intended CUDA wheel).

setuptools<71.0.0 being present in both dependency sets does not itself make pip reuse the build environment’s resolved PyTorch; PEP 517 isolation resolves build requirements separately. --build-constraint constrains that isolated resolution, while --constraint constrains the target install. There is no pip option that automatically feeds the first resolver’s selected versions into the second.


# recreate the image without the installed CUDA packages then copy the installed MONAI and Python directories
FROM ${IMAGE} AS build2
Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pynrrd
pydicom
h5py
nni==2.10.1; platform_system == "Linux" and "arm" not in platform_machine and "aarch" not in platform_machine
filelock<3.12.0
optuna
opencv-python-headless
onnx>=1.13.0
Expand Down
Loading
Loading