Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
	•	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 <[email protected]>
  • Loading branch information
kartikshastrakar committed Sep 26, 2024
1 parent ec2cc83 commit ca9e194
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,34 +18,35 @@ LABEL maintainer="[email protected]"

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

0 comments on commit ca9e194

Please sign in to comment.