Skip to content

Commit 35e538d

Browse files
authored
fix dockerfile definitions. (huggingface#12424)
* fix dockerfile definitions. * python 3.10 slim. * up * up * up * up * up * revert pr_tests.yml changes * up * up * reduce python version for torch 2.1.0
1 parent 2dc3167 commit 35e538d

File tree

7 files changed

+136
-172
lines changed

7 files changed

+136
-172
lines changed

.github/workflows/build_docker_images.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ jobs:
7272
image-name:
7373
- diffusers-pytorch-cpu
7474
- diffusers-pytorch-cuda
75-
- diffusers-pytorch-cuda
7675
- diffusers-pytorch-xformers-cuda
7776
- diffusers-pytorch-minimum-cuda
7877
- diffusers-doc-builder

.github/workflows/pr_tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,3 @@ jobs:
286286
with:
287287
name: pr_main_test_reports
288288
path: reports
289-
Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,42 @@
1-
FROM ubuntu:20.04
1+
FROM python:3.10-slim
2+
ENV PYTHONDONTWRITEBYTECODE=1
23
LABEL maintainer="Hugging Face"
34
LABEL repository="diffusers"
45

56
ENV DEBIAN_FRONTEND=noninteractive
67

7-
RUN apt-get -y update \
8-
&& apt-get install -y software-properties-common \
9-
&& add-apt-repository ppa:deadsnakes/ppa
10-
11-
RUN apt install -y bash \
12-
build-essential \
13-
git \
14-
git-lfs \
15-
curl \
16-
ca-certificates \
17-
libsndfile1-dev \
18-
python3.10 \
19-
python3-pip \
20-
libgl1 \
21-
zip \
22-
wget \
23-
python3.10-venv && \
24-
rm -rf /var/lib/apt/lists
25-
26-
# make sure to use venv
27-
RUN python3.10 -m venv /opt/venv
28-
ENV PATH="/opt/venv/bin:$PATH"
8+
RUN apt-get -y update && apt-get install -y bash \
9+
build-essential \
10+
git \
11+
git-lfs \
12+
curl \
13+
ca-certificates \
14+
libsndfile1-dev \
15+
libgl1
16+
17+
ENV UV_PYTHON=/usr/local/bin/python
2918

3019
# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
31-
RUN python3.10 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \
32-
python3.10 -m uv pip install --no-cache-dir \
33-
torch \
34-
torchvision \
35-
torchaudio \
36-
invisible_watermark \
37-
--extra-index-url https://download.pytorch.org/whl/cpu && \
38-
python3.10 -m uv pip install --no-cache-dir \
39-
accelerate \
40-
datasets \
41-
hf-doc-builder \
42-
huggingface-hub \
43-
Jinja2 \
44-
librosa \
45-
numpy==1.26.4 \
46-
scipy \
47-
tensorboard \
48-
transformers \
49-
matplotlib \
50-
setuptools==69.5.1 \
51-
bitsandbytes \
52-
torchao \
53-
gguf \
54-
optimum-quanto
20+
RUN pip install uv
21+
RUN uv pip install --no-cache-dir \
22+
torch \
23+
torchvision \
24+
torchaudio \
25+
--extra-index-url https://download.pytorch.org/whl/cpu
26+
27+
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers.git@main#egg=diffusers[test]"
28+
29+
# Extra dependencies
30+
RUN uv pip install --no-cache-dir \
31+
accelerate \
32+
numpy==1.26.4 \
33+
hf_transfer \
34+
setuptools==69.5.1 \
35+
bitsandbytes \
36+
torchao \
37+
gguf \
38+
optimum-quanto
39+
40+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
5541

5642
CMD ["/bin/bash"]
Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,37 @@
1-
FROM ubuntu:20.04
1+
FROM python:3.10-slim
2+
ENV PYTHONDONTWRITEBYTECODE=1
23
LABEL maintainer="Hugging Face"
34
LABEL repository="diffusers"
45

56
ENV DEBIAN_FRONTEND=noninteractive
67

7-
RUN apt-get -y update \
8-
&& apt-get install -y software-properties-common \
9-
&& add-apt-repository ppa:deadsnakes/ppa
10-
11-
RUN apt install -y bash \
12-
build-essential \
13-
git \
14-
git-lfs \
15-
curl \
16-
ca-certificates \
17-
libsndfile1-dev \
18-
python3.10 \
19-
python3.10-dev \
20-
python3-pip \
21-
libgl1 \
22-
python3.10-venv && \
23-
rm -rf /var/lib/apt/lists
24-
25-
# make sure to use venv
26-
RUN python3.10 -m venv /opt/venv
27-
ENV PATH="/opt/venv/bin:$PATH"
8+
RUN apt-get -y update && apt-get install -y bash \
9+
build-essential \
10+
git \
11+
git-lfs \
12+
curl \
13+
ca-certificates \
14+
libsndfile1-dev \
15+
libgl1
16+
17+
ENV UV_PYTHON=/usr/local/bin/python
2818

2919
# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
30-
RUN python3.10 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \
31-
python3.10 -m uv pip install --no-cache-dir \
32-
torch \
33-
torchvision \
34-
torchaudio \
35-
invisible_watermark \
36-
--extra-index-url https://download.pytorch.org/whl/cpu && \
37-
python3.10 -m uv pip install --no-cache-dir \
38-
accelerate \
39-
datasets \
40-
hf-doc-builder \
41-
huggingface-hub \
42-
Jinja2 \
43-
librosa \
44-
numpy==1.26.4 \
45-
scipy \
46-
tensorboard \
47-
transformers matplotlib \
48-
hf_transfer
20+
RUN pip install uv
21+
RUN uv pip install --no-cache-dir \
22+
torch \
23+
torchvision \
24+
torchaudio \
25+
--extra-index-url https://download.pytorch.org/whl/cpu
26+
27+
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers.git@main#egg=diffusers[test]"
28+
29+
# Extra dependencies
30+
RUN uv pip install --no-cache-dir \
31+
accelerate \
32+
numpy==1.26.4 \
33+
hf_transfer
34+
35+
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get autoremove && apt-get autoclean
4936

5037
CMD ["/bin/bash"]

docker/diffusers-pytorch-cuda/Dockerfile

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ FROM nvidia/cuda:12.1.0-runtime-ubuntu20.04
22
LABEL maintainer="Hugging Face"
33
LABEL repository="diffusers"
44

5+
ARG PYTHON_VERSION=3.12
56
ENV DEBIAN_FRONTEND=noninteractive
67

78
RUN apt-get -y update \
89
&& apt-get install -y software-properties-common \
9-
&& add-apt-repository ppa:deadsnakes/ppa
10+
&& add-apt-repository ppa:deadsnakes/ppa && \
11+
apt-get update
1012

1113
RUN apt install -y bash \
1214
build-essential \
@@ -16,36 +18,31 @@ RUN apt install -y bash \
1618
ca-certificates \
1719
libsndfile1-dev \
1820
libgl1 \
19-
python3.10 \
20-
python3.10-dev \
21+
python3 \
2122
python3-pip \
22-
python3.10-venv && \
23-
rm -rf /var/lib/apt/lists
23+
&& apt-get clean \
24+
&& rm -rf /var/lib/apt/lists/*
2425

25-
# make sure to use venv
26-
RUN python3.10 -m venv /opt/venv
27-
ENV PATH="/opt/venv/bin:$PATH"
26+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
27+
ENV PATH="/root/.local/bin:$PATH"
28+
ENV VIRTUAL_ENV="/opt/venv"
29+
ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python
30+
RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV}
31+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
2832

2933
# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
30-
RUN python3.10 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \
31-
python3.10 -m uv pip install --no-cache-dir \
34+
RUN uv pip install --no-cache-dir \
3235
torch \
3336
torchvision \
34-
torchaudio \
35-
invisible_watermark && \
36-
python3.10 -m pip install --no-cache-dir \
37+
torchaudio
38+
39+
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers.git@main#egg=diffusers[test]"
40+
41+
# Extra dependencies
42+
RUN uv pip install --no-cache-dir \
3743
accelerate \
38-
datasets \
39-
hf-doc-builder \
40-
huggingface-hub \
41-
hf_transfer \
42-
Jinja2 \
43-
librosa \
4444
numpy==1.26.4 \
45-
scipy \
46-
tensorboard \
47-
transformers \
48-
pytorch-lightning \
45+
pytorch-lightning \
4946
hf_transfer
5047

5148
CMD ["/bin/bash"]

docker/diffusers-pytorch-minimum-cuda/Dockerfile

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ FROM nvidia/cuda:12.1.0-runtime-ubuntu20.04
22
LABEL maintainer="Hugging Face"
33
LABEL repository="diffusers"
44

5+
ARG PYTHON_VERSION=3.10
56
ENV DEBIAN_FRONTEND=noninteractive
67
ENV MINIMUM_SUPPORTED_TORCH_VERSION="2.1.0"
78
ENV MINIMUM_SUPPORTED_TORCHVISION_VERSION="0.16.0"
89
ENV MINIMUM_SUPPORTED_TORCHAUDIO_VERSION="2.1.0"
910

1011
RUN apt-get -y update \
1112
&& apt-get install -y software-properties-common \
12-
&& add-apt-repository ppa:deadsnakes/ppa
13+
&& add-apt-repository ppa:deadsnakes/ppa && \
14+
apt-get update
1315

1416
RUN apt install -y bash \
1517
build-essential \
@@ -19,35 +21,31 @@ RUN apt install -y bash \
1921
ca-certificates \
2022
libsndfile1-dev \
2123
libgl1 \
22-
python3.10 \
23-
python3.10-dev \
24+
python3 \
2425
python3-pip \
25-
python3.10-venv && \
26-
rm -rf /var/lib/apt/lists
26+
&& apt-get clean \
27+
&& rm -rf /var/lib/apt/lists/*
2728

28-
# make sure to use venv
29-
RUN python3.10 -m venv /opt/venv
30-
ENV PATH="/opt/venv/bin:$PATH"
29+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
30+
ENV PATH="/root/.local/bin:$PATH"
31+
ENV VIRTUAL_ENV="/opt/venv"
32+
ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python
33+
RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV}
34+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
3135

3236
# pre-install the heavy dependencies (these can later be overridden by the deps from setup.py)
33-
RUN python3.10 -m pip install --no-cache-dir --upgrade pip uv==0.1.11 && \
34-
python3.10 -m uv pip install --no-cache-dir \
37+
RUN uv pip install --no-cache-dir \
3538
torch==$MINIMUM_SUPPORTED_TORCH_VERSION \
3639
torchvision==$MINIMUM_SUPPORTED_TORCHVISION_VERSION \
37-
torchaudio==$MINIMUM_SUPPORTED_TORCHAUDIO_VERSION \
38-
invisible_watermark && \
39-
python3.10 -m pip install --no-cache-dir \
40+
torchaudio==$MINIMUM_SUPPORTED_TORCHAUDIO_VERSION
41+
42+
RUN uv pip install --no-cache-dir "git+https://github.com/huggingface/diffusers.git@main#egg=diffusers[test]"
43+
44+
# Extra dependencies
45+
RUN uv pip install --no-cache-dir \
4046
accelerate \
41-
datasets \
42-
hf-doc-builder \
43-
huggingface-hub \
44-
hf_transfer \
45-
Jinja2 \
46-
librosa \
4747
numpy==1.26.4 \
48-
scipy \
49-
tensorboard \
50-
transformers \
48+
pytorch-lightning \
5149
hf_transfer
5250

5351
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)