-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Docker Slim Image #8640
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
base: dev
Are you sure you want to change the base?
Docker Slim Image #8640
Changes from all commits
510987d
983a833
566c2bc
a07a861
47b3ce3
463bb91
23b7fb6
5e7283f
7942ab3
9887f81
4e7d7c5
cd88b32
3cdf717
4d6e1bb
fc937d0
90fb7ef
7421580
8aae06a
d83ab34
39ecb09
803fba4
ee7afe8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Copyright (c) MONAI Consortium | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # To build with a different base image | ||
| # please run `docker build` using the `--build-arg IMAGE=...` flag. | ||
| ARG IMAGE=debian:12-slim | ||
|
|
||
| FROM ${IMAGE} AS build | ||
|
|
||
| ARG TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6 8.9 9.0+PTX" | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV APT_INSTALL="apt install -y --no-install-recommends" | ||
|
|
||
| RUN apt update && apt upgrade -y && \ | ||
| ${APT_INSTALL} ca-certificates python3-pip python-is-python3 git wget libopenslide0 unzip python3-dev && \ | ||
| 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 && \ | ||
| rm -rf /usr/lib/python*/EXTERNALLY-MANAGED /var/lib/apt/lists/* && \ | ||
| 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 \ | ||
| CFLAGS="-O3" DISABLE_NUMCODECS_SSE2=true DISABLE_NUMCODECS_AVX2=true python -m pip install numcodecs; \ | ||
| fi | ||
|
|
||
| # NGC Client | ||
| WORKDIR /opt/tools | ||
| ARG NGC_CLI_URI="https://ngc.nvidia.com/downloads/ngccli_linux.zip" | ||
| RUN wget -q ${NGC_CLI_URI} && unzip ngccli_linux.zip && chmod u+x ngc-cli/ngc && \ | ||
| find ngc-cli/ -type f -exec md5sum {} + | LC_ALL=C sort | md5sum -c ngc-cli.md5 && \ | ||
| rm -rf ngccli_linux.zip ngc-cli.md5 | ||
|
|
||
| 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 ./ | ||
| COPY tests ./tests | ||
| COPY monai ./monai | ||
|
|
||
| # install full deps | ||
| RUN python -m pip install --no-cache-dir -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 | ||
|
|
||
| # recreate the image without the installed CUDA packages then copy the installed MONAI and Python directories | ||
| FROM ${IMAGE} AS build2 | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| ENV APT_INSTALL="apt install -y --no-install-recommends" | ||
|
|
||
| RUN apt update && apt upgrade -y && \ | ||
| ${APT_INSTALL} ca-certificates python3-pip python-is-python3 git libopenslide0 && \ | ||
| apt clean && \ | ||
| rm -rf /usr/lib/python*/EXTERNALLY-MANAGED /var/lib/apt/lists/* && \ | ||
| python -m pip install --upgrade --no-cache-dir pip | ||
|
|
||
| COPY --from=build /opt/monai /opt/monai | ||
| COPY --from=build /opt/tools /opt/tools | ||
| ARG PYTHON_VERSION=3.11 | ||
| COPY --from=build /usr/local/lib/python${PYTHON_VERSION}/dist-packages /usr/local/lib/python${PYTHON_VERSION}/dist-packages | ||
| COPY --from=build /usr/local/bin /usr/local/bin | ||
|
|
||
| RUN rm -rf /opt/monai/build /opt/monai/monai.egg-info && \ | ||
| find / -name __pycache__ | xargs rm -rf | ||
|
|
||
| # flatten all layers down to one | ||
| FROM ${IMAGE} | ||
| LABEL maintainer="[email protected]" | ||
|
|
||
| COPY --from=build2 / / | ||
|
|
||
| WORKDIR /opt/monai | ||
|
|
||
| ENV PATH=${PATH}:/opt/tools:/opt/tools/ngc-cli | ||
| ENV POLYGRAPHY_AUTOINSTALL_DEPS=1 | ||
| ENV CUDA_HOME=/usr/local/cuda | ||
| ENV BUILD_MONAI=1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| # Full requirements for developments | ||
| -r requirements-min.txt | ||
| pytorch-ignite==0.4.11 | ||
| pytorch-ignite | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Major BC change after v0.4.11
Notes/citations
References 🏁 Script executed: #!/bin/bash
# Search for pytorch-ignite usage in the codebase, particularly ignite.contrib imports
rg "ignite\." --type py | head -30Repository: Project-MONAI/MONAI Length of output: 182 🌐 Web query:
💡 Result: Short answer: In v0.5.0 the ignite.contrib package was removed as a location for maintained handlers/metrics — items from ignite.contrib.handlers and ignite.contrib.metrics were moved into the main packages (ignite.handlers, ignite.metrics, ignite.loggers, etc.). Update your imports accordingly. What changed (practical migration):
References:
If you want, tell me one or two specific contrib imports you use and I’ll give the exact new import lines and any small API differences. Sources Unpinning pytorch-ignite introduces breaking changes—verify MONAI's ignite imports before merging. pytorch-ignite v0.5.0 removed the 🤖 Prompt for AI Agents |
||
| gdown>=4.7.3 | ||
| scipy>=1.12.0; python_version >= '3.9' | ||
| itk>=5.2 | ||
|
|
@@ -52,8 +52,8 @@ nni==2.10.1; platform_system == "Linux" and "arm" not in platform_machine and "a | |
| optuna | ||
| git+https://github.com/Project-MONAI/MetricsReloaded@monai-support#egg=MetricsReloaded | ||
| onnx>=1.13.0 | ||
| onnxruntime | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Short answer: Use Python 3.11 for reliable ONNX Runtime support; Python 3.12 support in 2025 is partial and platform-dependent (not consistently available via official pip wheels). Details & evidence:
Recommendation: For production or wide-platform compatibility in Dec 2025 use Python 3.11. If you must use Python 3.12, confirm availability for your OS/arch by checking the ONNX Runtime GitHub releases or package indexes (pip wheels list and conda-forge) for the exact version you plan to install. (github.com) Citations:
Unpinned onnxruntime may fail on Python 3.12 due to missing platform-specific wheels. Removing the python_version condition creates an installation risk: Python 3.11 has official support (v1.15.0+), but Python 3.12 wheels are not consistently available via official pip repositories. "No matching distribution" errors are reported on various platforms for Python 3.12. Community builds via conda-forge provide partial coverage. Consider either:
🤖 Prompt for AI Agents |
||
| onnxscript | ||
| onnxruntime; python_version <= '3.10' | ||
| typeguard<3 # https://github.com/microsoft/nni/issues/5457 | ||
| filelock<3.12.0 # https://github.com/microsoft/nni/issues/5523 | ||
| zarr | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| torch>=2.4.1; platform_system != "Windows" | ||
| torch>=2.4.1, !=2.7.0; platform_system == "Windows" | ||
| torch>=2.4.1, <2.9; platform_system != "Windows" | ||
| torch>=2.4.1, <2.9, !=2.7.0; platform_system == "Windows" | ||
| numpy>=1.24,<3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove escape before
>=in torch dependency.Line 174 escapes
>=as\>=, but line 114 shows the correct pattern without escaping. The backslash will likely cause pip to receive an invalid version specifier. Unescaped>=works correctly inside double quotes in bash.Apply this diff:
🤖 Prompt for AI Agents