Skip to content

Commit 3f9b772

Browse files
authored
Merge pull request #1038 from mlcommons/using_uv_for_docker_images
Updated docker image recipe for speed
2 parents a2ab6d0 + d9e237a commit 3f9b772

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

.spelling/.spelling/excludes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
^\QGANDLF/grad_clipping/__init__.py\E$
99
^\QGANDLF/models/seg_modules/__init__.py\E$
1010
^\QGANDLF/privacy/__init__.py\E$
11+
^\QGANDLF/configuration/__init__.py\E$
1112
^\Qtesting/__init__.py\E$
13+
^\Qsetup.py\E$
1214
^\Qtutorials/classification_medmnist_notebook/tutorial.ipynb\E$
1315
^samples/images_opm/
1416
^tutorials/classification_medmnist_notebook/medmnist/dataset/

Dockerfile-CPU

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ARG DEBIAN_FRONTEND=noninteractive
77

88
# Install fresh Python and dependencies for build-from-source
99
RUN apt-get update && apt-get install -y software-properties-common
10+
RUN apt-get install -y git
1011
RUN add-apt-repository ppa:deadsnakes/ppa
1112
RUN apt install -y python3.11
1213
RUN apt install -y libpython3.11-dev
@@ -18,18 +19,19 @@ RUN apt install -y python3-pip
1819
RUN apt-get install -y libjpeg8-dev zlib1g-dev libffi-dev libgl1
1920
# fix pip version because of weird PyYAML issue
2021
RUN python3.11 -m pip install --upgrade pip
22+
RUN python3.11 -m pip install uv
2123
# EXPLICITLY install cpu versions of torch/torchvision (not all versions have +cpu modes on PyPI...)
22-
RUN python3.11 -m pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cpu
23-
RUN python3.11 -m pip install openvino-dev opencv-python-headless
24+
RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cpu --system
25+
RUN uv pip install openvino-dev opencv-python-headless --system
2426

2527
# Do some dependency installation separately here to make layer caching more efficient
2628
COPY ./setup.py ./setup.py
2729
RUN python3.11 -c "from setup import requirements; file = open('requirements.txt', 'w'); file.writelines([req + '\n' for req in requirements]); file.close()" \
28-
&& python3.11 -m pip install -r ./requirements.txt
30+
&& uv pip install -r ./requirements.txt --system
2931

3032
COPY . /GaNDLF
3133
WORKDIR /GaNDLF
32-
RUN python3.11 -m pip install -e .
34+
RUN uv pip install -e . --system
3335
# Entrypoint forces all commands given via "docker run" to go through python, CMD forces the default entrypoint script argument to be gandlf run
3436
# If a user calls "docker run gandlf:[tag] anonymize", it will resolve to running "gandlf anonymize" instead.
3537
# CMD is inherently overridden by args to "docker run", entrypoint is constant.

Dockerfile-CUDA11.8

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ENV DEBIAN_FRONTEND=noninteractive
1010

1111
# Explicitly install python3.11 (this uses 11.1 for now, as PyTorch LTS 1.8.2 is built against it)
1212
RUN apt-get update && apt-get install -y software-properties-common
13+
RUN apt-get install -y git
1314
RUN add-apt-repository ppa:deadsnakes/ppa
1415
RUN apt install -y python3.11
1516
RUN apt install -y libpython3.11-dev
@@ -21,17 +22,18 @@ RUN apt install -y python3-pip
2122
RUN apt-get install -y libjpeg8-dev zlib1g-dev libffi-dev libgl1
2223
# fix pip version because of weird PyYAML issue
2324
RUN python3.11 -m pip install --upgrade pip
24-
RUN python3.11 -m pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu118
25-
RUN python3.11 -m pip install openvino-dev opencv-python-headless
25+
RUN python3.11 -m pip install uv
26+
RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu118 --system
27+
RUN uv pip install openvino-dev opencv-python-headless --system
2628

2729
# Do some dependency installation separately here to make layer caching more efficient
2830
COPY ./setup.py ./setup.py
2931
RUN python3.11 -c "from setup import requirements; file = open('requirements.txt', 'w'); file.writelines([req + '\n' for req in requirements]); file.close()" \
30-
&& python3.11 -m pip install -r ./requirements.txt
32+
&& uv pip install -r ./requirements.txt --system
3133

3234
COPY . /GaNDLF
3335
WORKDIR /GaNDLF
34-
RUN python3.11 -m pip install -e .
36+
RUN uv pip install -e . --system
3537

3638
# Entrypoint forces all commands given via "docker run" to go through python, CMD forces the default entrypoint script argument to be gandlf run
3739
# If a user calls "docker run gandlf:[tag] anonymize", it will resolve to running "gandlf anonymize" instead.

Dockerfile-CUDA12.6

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ENV DEBIAN_FRONTEND=noninteractive
1010

1111
# Explicitly install python3.11 (this uses 11.1 for now, as PyTorch LTS 1.8.2 is built against it)
1212
RUN apt-get update && apt-get install -y software-properties-common
13+
RUN apt-get install -y git
1314
RUN add-apt-repository ppa:deadsnakes/ppa
1415
RUN apt install -y python3.11
1516
RUN apt install -y libpython3.11-dev
@@ -21,17 +22,18 @@ RUN apt install -y python3-pip
2122
RUN apt-get install -y libjpeg8-dev zlib1g-dev libffi-dev libgl1
2223
# fix pip version because of weird PyYAML issue
2324
RUN python3.11 -m pip install --upgrade pip
24-
RUN python3.11 -m pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu126
25-
RUN python3.11 -m pip install openvino-dev opencv-python-headless
25+
RUN python3.11 -m pip install uv
26+
RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu126 --system
27+
RUN uv pip install openvino-dev opencv-python-headless --system
2628

2729
# Do some dependency installation separately here to make layer caching more efficient
2830
COPY ./setup.py ./setup.py
2931
RUN python3.11 -c "from setup import requirements; file = open('requirements.txt', 'w'); file.writelines([req + '\n' for req in requirements]); file.close()" \
30-
&& python3.11 -m pip install -r ./requirements.txt
32+
&& uv pip install -r ./requirements.txt --system
3133

3234
COPY . /GaNDLF
3335
WORKDIR /GaNDLF
34-
RUN python3.11 -m pip install -e .
36+
RUN uv pip install -e . --system
3537

3638
# Entrypoint forces all commands given via "docker run" to go through python, CMD forces the default entrypoint script argument to be gandlf run
3739
# If a user calls "docker run gandlf:[tag] anonymize", it will resolve to running "gandlf anonymize" instead.

Dockerfile-ROCm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ LABEL version=1.0
88

99
# The base image contains ROCm, python 3.9 and pytorch already, no need to install those
1010
RUN apt-get update && apt-get install -y software-properties-common
11+
RUN apt-get install -y git
1112
RUN add-apt-repository ppa:deadsnakes/ppa
1213
RUN apt install -y python3.11
1314
RUN apt install -y libpython3.11-dev
@@ -19,17 +20,18 @@ RUN apt install -y python3-pip
1920
RUN apt-get install -y python3.11 python3-pip libjpeg8-dev zlib1g-dev python3-dev libpython3.11-dev libffi-dev libgl1
2021
# fix pip version because of weird PyYAML issue
2122
RUN python3.11 -m pip install --upgrade pip
22-
RUN python3.11 -m pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/rocm6.3
23-
RUN python3.11 -m pip install openvino-dev opencv-python-headless
23+
RUN python3.11 -m pip install uv
24+
RUN uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/rocm6.3 --system
25+
RUN uv pip install openvino-dev opencv-python-headless --system
2426

2527
# Do some dependency installation separately here to make layer caching more efficient
2628
COPY ./setup.py ./setup.py
2729
RUN python3.11 -c "from setup import requirements; file = open('requirements.txt', 'w'); file.writelines([req + '\n' for req in requirements]); file.close()" \
28-
&& python3.11 -m pip install -r ./requirements.txt
30+
&& uv pip install -r ./requirements.txt --system
2931

3032
COPY . /GaNDLF
3133
WORKDIR /GaNDLF
32-
RUN python3.11 -m pip install -e .
34+
RUN uv pip install -e . --system
3335

3436
# Entrypoint forces all commands given via "docker run" to go through python, CMD forces the default entrypoint script argument to be gandlf run
3537
# If a user calls "docker run gandlf:[tag] anonymize", it will resolve to running "gandlf anonymize" instead.

0 commit comments

Comments
 (0)