From ca9e194c385a43359d4b49e88adf88646a880dce Mon Sep 17 00:00:00 2001 From: Kartik Shastrakar <81631437+kartikshastrakar@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:21:26 +0530 Subject: [PATCH] Update Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Updated the PYTORCH_IMAGE to 23.08-py3, but ensure it’s still relevant for your application. • The requirements.txt handling avoids potential issues with conflicting torch versions, by removing it from the list before installing. • NGC client installation is optimized, and we use MD5 checks to ensure proper download. • Reduced Docker image size by cleaning up the apt cache and build files. Signed-off-by: Kartik Shastrakar <81631437+kartikshastrakar@users.noreply.github.com> --- Dockerfile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index cb1300ea90..d0c11210bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # 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 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 @@ -18,34 +18,35 @@ LABEL maintainer="monai.contact@gmail.com" WORKDIR /opt/monai -# install full deps +# Install full dependencies, remove PyTorch from requirements to avoid conflicts 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 pip \ && python -m pip install --no-cache-dir -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... - +# Compile extensions and clean up temporary files 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 +# NGC Client setup 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 +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 ENV PATH=${PATH}:/opt/tools:/opt/tools/ngc-cli + +# Install additional dependencies RUN apt-get update \ && DEBIAN_FRONTEND="noninteractive" apt-get install -y libopenslide0 \ && rm -rf /var/lib/apt/lists/* -# append /opt/tools to runtime path for NGC CLI to be accessible from all file system locations + +# Append /opt/tools to runtime path for NGC CLI to be accessible from all file system locations ENV PATH=${PATH}:/opt/tools + WORKDIR /opt/monai