Skip to content

Commit 0727031

Browse files
committed
{slims} Add constraints for PyTorch version
1 parent b01b48c commit 0727031

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

cu126-slim/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,26 @@ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
216216
# Deps for ComfyUI & custom nodes
217217
COPY builder-scripts/. /builder-scripts/
218218

219+
# Generate a version constraints file to pin PyTorch (prevent later installs from changing its version)
220+
RUN pip list --format=freeze \
221+
| awk -F== 'BEGIN{want["torch"]=1;want["torchvision"]=1;want["torchaudio"]=1} $1 in want{print $1 "==" $2}' \
222+
> /builder-scripts/constraints.txt \
223+
&& echo "Pinned PyTorch version:" \
224+
&& cat /builder-scripts/constraints.txt
225+
219226
RUN --mount=type=cache,target=/root/.cache/pip \
220227
pip install \
228+
-c /builder-scripts/constraints.txt \
221229
-r /builder-scripts/pak3.txt
222230

223231
RUN --mount=type=cache,target=/root/.cache/pip \
224232
pip install \
233+
-c /builder-scripts/constraints.txt \
225234
-r /builder-scripts/pak5.txt
226235

227236
RUN --mount=type=cache,target=/root/.cache/pip \
228237
pip install \
238+
-c /builder-scripts/constraints.txt \
229239
-r /builder-scripts/pak7.txt
230240

231241
# TempFix: Prevent SAM-2 from installing CUDA packages
@@ -248,6 +258,7 @@ RUN bash /builder-scripts/preload-cache.sh
248258
# Install deps (comfyui-frontend-package, etc) pair to the preloaded ComfyUI version
249259
RUN --mount=type=cache,target=/root/.cache/pip \
250260
pip install \
261+
-c /builder-scripts/constraints.txt \
251262
-r '/default-comfyui-bundle/ComfyUI/requirements.txt' \
252263
-r '/default-comfyui-bundle/ComfyUI/custom_nodes/ComfyUI-Manager/requirements.txt' \
253264
&& pip list

cu128-slim/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,26 @@ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
216216
# Deps for ComfyUI & custom nodes
217217
COPY builder-scripts/. /builder-scripts/
218218

219+
# Generate a version constraints file to pin PyTorch (prevent later installs from changing its version)
220+
RUN pip list --format=freeze \
221+
| awk -F== 'BEGIN{want["torch"]=1;want["torchvision"]=1;want["torchaudio"]=1} $1 in want{print $1 "==" $2}' \
222+
> /builder-scripts/constraints.txt \
223+
&& echo "Pinned PyTorch version:" \
224+
&& cat /builder-scripts/constraints.txt
225+
219226
RUN --mount=type=cache,target=/root/.cache/pip \
220227
pip install \
228+
-c /builder-scripts/constraints.txt \
221229
-r /builder-scripts/pak3.txt
222230

223231
RUN --mount=type=cache,target=/root/.cache/pip \
224232
pip install \
233+
-c /builder-scripts/constraints.txt \
225234
-r /builder-scripts/pak5.txt
226235

227236
RUN --mount=type=cache,target=/root/.cache/pip \
228237
pip install \
238+
-c /builder-scripts/constraints.txt \
229239
-r /builder-scripts/pak7.txt
230240

231241
################################################################################
@@ -238,6 +248,7 @@ RUN bash /builder-scripts/preload-cache.sh
238248
# Install deps (comfyui-frontend-package, etc) pair to the preloaded ComfyUI version
239249
RUN --mount=type=cache,target=/root/.cache/pip \
240250
pip install \
251+
-c /builder-scripts/constraints.txt \
241252
-r '/default-comfyui-bundle/ComfyUI/requirements.txt' \
242253
-r '/default-comfyui-bundle/ComfyUI/custom_nodes/ComfyUI-Manager/requirements.txt' \
243254
&& pip list

cu130-slim/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,26 @@ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
210210
# Deps for ComfyUI & custom nodes
211211
COPY builder-scripts/. /builder-scripts/
212212

213+
# Generate a version constraints file to pin PyTorch (prevent later installs from changing its version)
214+
RUN pip list --format=freeze \
215+
| awk -F== 'BEGIN{want["torch"]=1;want["torchvision"]=1;want["torchaudio"]=1} $1 in want{print $1 "==" $2}' \
216+
> /builder-scripts/constraints.txt \
217+
&& echo "Pinned PyTorch version:" \
218+
&& cat /builder-scripts/constraints.txt
219+
213220
RUN --mount=type=cache,target=/root/.cache/pip \
214221
pip install \
222+
-c /builder-scripts/constraints.txt \
215223
-r /builder-scripts/pak3.txt
216224

217225
RUN --mount=type=cache,target=/root/.cache/pip \
218226
pip install \
227+
-c /builder-scripts/constraints.txt \
219228
-r /builder-scripts/pak5.txt
220229

221230
RUN --mount=type=cache,target=/root/.cache/pip \
222231
pip install \
232+
-c /builder-scripts/constraints.txt \
223233
-r /builder-scripts/pak7.txt
224234

225235
################################################################################
@@ -232,6 +242,7 @@ RUN bash /builder-scripts/preload-cache.sh
232242
# Install deps (comfyui-frontend-package, etc) pair to the preloaded ComfyUI version
233243
RUN --mount=type=cache,target=/root/.cache/pip \
234244
pip install \
245+
-c /builder-scripts/constraints.txt \
235246
-r '/default-comfyui-bundle/ComfyUI/requirements.txt' \
236247
-r '/default-comfyui-bundle/ComfyUI/custom_nodes/ComfyUI-Manager/requirements.txt' \
237248
&& pip list

0 commit comments

Comments
 (0)