1
- ARG CUDA_VERSION=12.6.3
2
- ARG IMAGE_DISTRO=ubuntu24 .04
1
+ ARG CUDA_VERSION=12.4.1
2
+ ARG IMAGE_DISTRO=ubuntu22 .04
3
3
ARG PYTHON_VERSION=3.12
4
4
5
5
# ---------- Builder Base ----------
6
6
FROM nvcr.io/nvidia/cuda:${CUDA_VERSION}-devel-${IMAGE_DISTRO} AS base
7
7
8
+ # Job scaling
9
+ ARG MAX_JOBS=32
10
+ ENV MAX_JOBS=${MAX_JOBS}
11
+ ARG NVCC_THREADS=2
12
+ ENV NVCC_THREADS=${NVCC_THREADS}
13
+
8
14
# Set arch lists for all targets
9
15
# 'a' suffix is not forward compatible but enables all optimizations
10
16
ARG TORCH_CUDA_ARCH_LIST="9.0a"
@@ -17,19 +23,17 @@ ENV DEBIAN_FRONTEND=noninteractive
17
23
RUN apt update
18
24
RUN apt upgrade -y
19
25
RUN apt install -y --no-install-recommends \
20
- curl \
21
- git \
22
- libibverbs-dev \
23
- zlib1g-dev
24
-
25
- # Clean apt cache
26
- RUN apt clean
27
- RUN rm -rf /var/lib/apt/lists/*
28
- RUN rm -rf /var/cache/apt/archives
26
+ curl \
27
+ gcc-12 g++-12 \
28
+ git \
29
+ libibverbs-dev \
30
+ libjpeg-turbo8-dev \
31
+ libpng-dev \
32
+ zlib1g-dev
29
33
30
34
# Set compiler paths
31
- ENV CC=/usr/bin/gcc
32
- ENV CXX=/usr/bin/g++
35
+ ENV CC=/usr/bin/gcc-12
36
+ ENV CXX=/usr/bin/g++-12
33
37
34
38
# Install uv
35
39
RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin sh
@@ -45,69 +49,146 @@ ENV PATH=${VIRTUAL_ENV}/bin:${PATH}
45
49
ENV CUDA_HOME=/usr/local/cuda
46
50
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
47
51
48
- # Install pytorch nightly
49
- RUN uv pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
50
-
51
52
FROM base AS build-base
52
53
RUN mkdir /wheels
53
54
54
55
# Install build deps that aren't in project requirements files
55
56
# Make sure to upgrade setuptools to avoid triton build bug
56
- RUN uv pip install -U build cmake ninja pybind11 setuptools wheel
57
+ # cmake '4.x' isn't parsed right by some tools yet
58
+ RUN uv pip install -U build "cmake<4" ninja pybind11 "setuptools<=76" wheel
59
+
60
+ # Handle arm64 torch build
61
+ FROM build-base AS build-torch
62
+ ARG TARGETARCH
63
+ RUN if [ ${TARGETARCH} = arm64 ]; then \
64
+ # Install NVPL for ARM64 \
65
+ apt install -y --no-install-recommends nvpl0 && \
66
+ export BLAS=NVPL && \
67
+ # ARM64 linker optimization \
68
+ export CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000 && \
69
+ export USE_PRIORITIZED_TEXT_FOR_LD=1; \
70
+ else \
71
+ uv pip install mkl-static mkl-include; \
72
+ fi
73
+
74
+ ARG TORCH_REF=v2.6.0
75
+ ARG TORCH_BUILD_VERSION=2.6.0+cu124
76
+ ENV PYTORCH_BUILD_VERSION=${TORCH_BUILD_VERSION:-${TORCH_REF#v}}
77
+ ENV PYTORCH_BUILD_NUMBER=0
78
+ RUN git clone https://github.com/pytorch/pytorch.git
79
+ RUN cd pytorch && \
80
+ git checkout ${TORCH_REF} && \
81
+ git submodule sync --recursive && \
82
+ git submodule update --init --recursive -j 8
83
+ # # Bump XNNPACK submodule ref to fix compilation bug \
84
+ # cd third_party/XNNPACK && \
85
+ # git checkout fcc06d1
86
+ RUN cd pytorch && \
87
+ uv pip install -r requirements.txt && \
88
+ uv build --wheel --no-build-isolation -o /wheels
89
+
90
+ FROM build-base AS build-audio
91
+ COPY --from=build-torch /wheels/*.whl wheels/
92
+ RUN uv pip install wheels/*
93
+
94
+ ARG AUDIO_REF=v2.6.0
95
+ ARG AUDIO_BUILD_VERSION=2.6.0+cu124
96
+ ENV BUILD_VERSION=${AUDIO_BUILD_VERSION:-${AUDIO_REF#v}}
97
+ RUN git clone https://github.com/pytorch/audio.git
98
+ RUN cd audio && \
99
+ git checkout ${AUDIO_REF} && \
100
+ git submodule sync --recursive && \
101
+ git submodule update --init --recursive -j 8
102
+ RUN cd audio && \
103
+ uv build --wheel --no-build-isolation -o /wheels
104
+
105
+ FROM build-base AS build-vision
106
+ COPY --from=build-torch /wheels/*.whl wheels/
107
+ RUN uv pip install wheels/*
108
+
109
+ ARG VISION_REF=v0.21.0
110
+ ARG VISION_BUILD_VERSION=0.21.0+cu124
111
+ ENV BUILD_VERSION=${VISION_BUILD_VERSION:-${VISION_REF#v}}
112
+ RUN git clone https://github.com/pytorch/vision.git
113
+ RUN cd vision && \
114
+ git checkout ${VISION_REF} && \
115
+ git submodule sync --recursive && \
116
+ git submodule update --init --recursive -j 8
117
+ RUN cd vision && \
118
+ uv build --wheel --no-build-isolation -o /wheels
57
119
58
120
FROM build-base AS build-triton
121
+ COPY --from=build-torch /wheels/*.whl wheels/
122
+ RUN uv pip install wheels/*
123
+
59
124
ARG TRITON_REF=release/3.2.x
60
- ARG TRITON_BUILD_SUFFIX=+cu126
125
+ ARG TRITON_BUILD_SUFFIX=+cu124
61
126
ENV TRITON_WHEEL_VERSION_SUFFIX=${TRITON_BUILD_SUFFIX:-}
62
127
RUN git clone https://github.com/triton-lang/triton.git
63
128
RUN cd triton && \
64
129
git checkout ${TRITON_REF} && \
65
- git submodule sync && \
66
- git submodule update --init --recursive -j 8 && \
130
+ git submodule sync --recursive && \
131
+ git submodule update --init --recursive -j 8
132
+ RUN cd triton && \
67
133
uv build python --wheel --no-build-isolation -o /wheels
68
134
69
135
FROM build-base AS build-xformers
136
+ COPY --from=build-torch /wheels/*.whl wheels/
137
+ RUN uv pip install wheels/*
138
+
70
139
ARG XFORMERS_REF=v0.0.29.post2
71
- ARG XFORMERS_BUILD_VERSION=0.0.29.post2+cu126
140
+ ARG XFORMERS_BUILD_VERSION=0.0.29.post2+cu124
72
141
ENV BUILD_VERSION=${XFORMERS_BUILD_VERSION:-${XFORMERS_REF#v}}
73
- RUN git clone https://github.com/facebookresearch/xformers.git
142
+ RUN git clone https://github.com/facebookresearch/xformers.git
74
143
RUN cd xformers && \
75
144
git checkout ${XFORMERS_REF} && \
76
- git submodule sync && \
77
- git submodule update --init --recursive -j 8 && \
145
+ git submodule sync --recursive && \
146
+ git submodule update --init --recursive -j 8
147
+ RUN cd xformers && \
78
148
uv build --wheel --no-build-isolation -o /wheels
79
149
80
150
FROM build-base AS build-flashinfer
151
+ COPY --from=build-torch /wheels/*.whl wheels/
152
+ RUN uv pip install wheels/*
153
+
81
154
ARG FLASHINFER_ENABLE_AOT=1
82
155
ARG FLASHINFER_REF=v0.2.2.post1
83
- ARG FLASHINFER_BUILD_SUFFIX=cu126
156
+ ARG FLASHINFER_BUILD_SUFFIX=cu124
84
157
ENV FLASHINFER_LOCAL_VERSION=${FLASHINFER_BUILD_SUFFIX:-}
85
158
RUN git clone https://github.com/flashinfer-ai/flashinfer.git
86
159
RUN cd flashinfer && \
87
160
git checkout ${FLASHINFER_REF} && \
88
- git submodule sync && \
89
- git submodule update --init --recursive -j 8 && \
161
+ git submodule sync --recursive && \
162
+ git submodule update --init --recursive -j 8
163
+ RUN cd flashinfer && \
90
164
uv build --wheel --no-build-isolation -o /wheels
91
165
92
166
FROM build-base AS build-vllm
93
- ARG VLLM_REF=v0.8.1
167
+ COPY --from=build-torch /wheels/*.whl wheels/
168
+ RUN uv pip install wheels/*
169
+
170
+ ARG VLLM_REF=v0.8.3
171
+ ARG VLLM_BUILD_VERSION=0.8.3
172
+ ENV BUILD_VERSION=${VLLM_BUILD_VERSION:-${VLLM_REF#v}}
173
+ ENV SETUPTOOLS_SCM_PRETEND_VERSION=${BUILD_VERSION:-:}
94
174
RUN git clone https://github.com/vllm-project/vllm.git
95
175
RUN cd vllm && \
96
176
git checkout ${VLLM_REF} && \
97
- git submodule sync && \
98
- git submodule update --init --recursive -j 8 && \
177
+ python use_existing_torch.py && \
99
178
uv pip install -r requirements/build.txt && \
100
179
uv build --wheel --no-build-isolation -o /wheels
101
180
102
181
FROM base AS vllm-openai
103
- COPY --from=build-flashinfer /wheels/* wheels/
104
- COPY --from=build-triton /wheels/* wheels/
105
- COPY --from=build-vllm /wheels/* wheels/
106
- COPY --from=build-xformers /wheels/* wheels/
182
+ COPY --from=build-torch /wheels/*.whl wheels/
183
+ COPY --from=build-audio /wheels/*.whl wheels/
184
+ COPY --from=build-vision /wheels/*.whl wheels/
185
+ COPY --from=build-flashinfer /wheels/*.whl wheels/
186
+ COPY --from=build-triton /wheels/*.whl wheels/
187
+ COPY --from=build-vllm /wheels/*.whl wheels/
188
+ COPY --from=build-xformers /wheels/*.whl wheels/
107
189
108
190
# Install and cleanup wheels
109
191
RUN uv pip install wheels/*
110
- RUN rm -r wheels
111
192
112
193
# Install pynvml
113
194
RUN uv pip install pynvml
@@ -118,6 +199,12 @@ RUN uv pip install accelerate hf_transfer modelscope bitsandbytes timm boto3 run
118
199
# Clean uv cache
119
200
RUN uv clean
120
201
202
+ # Clean apt cache
203
+ RUN apt autoremove --purge -y
204
+ RUN apt clean
205
+ RUN rm -rf /var/lib/apt/lists/*
206
+ RUN rm -rf /var/cache/apt/archives
207
+
121
208
# Enable hf-transfer
122
209
ENV HF_HUB_ENABLE_HF_TRANSFER=1
123
210
0 commit comments