Skip to content

Commit 2d0aa53

Browse files
dilipgbckhordiasma
authored andcommitted
fix:Build torch wheel inline rather than picking from nightly (vllm-project#18351)
Signed-off-by: Dilip Gowda Bhagavan <[email protected]>
1 parent 60c92f8 commit 2d0aa53

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

docker/Dockerfile.s390x

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,40 @@ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
8484
rustup default stable && \
8585
rustup show
8686

87+
FROM python-install AS torch
88+
ARG TORCH_VERSION=2.7.0
89+
ENV export _GLIBCXX_USE_CXX11_ABI=1
90+
ENV CARGO_HOME=/root/.cargo
91+
ENV RUSTUP_HOME=/root/.rustup
92+
ENV PATH="$CARGO_HOME/bin:$RUSTUP_HOME/bin:$PATH"
93+
94+
WORKDIR /tmp
95+
96+
RUN --mount=type=cache,target=/root/.cache/uv \
97+
--mount=type=bind,from=rust,source=/root/.cargo,target=/root/.cargo,rw \
98+
--mount=type=bind,from=rust,source=/root/.rustup,target=/root/.rustup,rw \
99+
git clone https://github.com/pytorch/pytorch.git && \
100+
cd pytorch && \
101+
git checkout v2.7.0 && \
102+
git submodule sync && \
103+
git submodule update --init --recursive && \
104+
uv pip install cmake ninja && \
105+
uv pip install -r requirements.txt && \
106+
python setup.py bdist_wheel
107+
108+
87109
FROM python-install AS torch-vision
88110
# Install torchvision
89-
ARG TORCH_VERSION=2.7.0.dev20250304
111+
ARG TORCH_VERSION=2.7.0
90112
ARG TORCH_VISION_VERSION=v0.20.1
91113
WORKDIR /tmp
92114
RUN --mount=type=cache,target=/root/.cache/uv \
115+
--mount=type=bind,from=torch,source=/tmp/pytorch/dist,target=/tmp/torch-wheels/ \
93116
git clone https://github.com/pytorch/vision.git && \
94117
cd vision && \
95118
git checkout $TORCH_VISION_VERSION && \
96-
uv pip install -v torch==${TORCH_VERSION} --extra-index-url https://download.pytorch.org/whl/nightly/cpu && \
119+
TORCH_WHL_FILE=$(ls /tmp/torch-wheels/*.whl | head -n 1) && \
120+
uv pip install -v $TORCH_WHL_FILE && \
97121
python setup.py bdist_wheel
98122

99123
FROM python-install AS hf-xet-builder
@@ -137,15 +161,17 @@ RUN --mount=type=cache,target=/root/.cache/uv \
137161
--mount=type=bind,from=pyarrow,source=/tmp/arrow/python/dist,target=/tmp/arrow-wheels \
138162
--mount=type=bind,from=torch-vision,source=/tmp/vision/dist,target=/tmp/vision-wheels/ \
139163
--mount=type=bind,from=hf-xet-builder,source=/tmp/hf-xet/dist,target=/tmp/hf-xet-wheels/ \
164+
--mount=type=bind,from=torch,source=/tmp/pytorch/dist,target=/tmp/torch-wheels/ \
140165
sed -i '/^torch/d' requirements/build.txt && \
141166
ARROW_WHL_FILE=$(ls /tmp/arrow-wheels/pyarrow-*.whl | head -n 1) && \
142167
VISION_WHL_FILE=$(ls /tmp/vision-wheels/*.whl | head -n 1) && \
143168
HF_XET_WHL_FILE=$(ls /tmp/hf-xet-wheels/*.whl | head -n 1) && \
169+
TORCH_WHL_FILE=$(ls /tmp/torch-wheels/*.whl | head -n 1) && \
144170
uv pip install -v \
145171
$ARROW_WHL_FILE \
146172
$VISION_WHL_FILE \
147173
$HF_XET_WHL_FILE \
148-
--extra-index-url https://download.pytorch.org/whl/nightly/cpu \
174+
$TORCH_WHL_FILE \
149175
--index-strategy unsafe-best-match \
150176
-r requirements/build.txt \
151177
-r requirements/cpu.txt

requirements/cpu.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
-r common.txt
33

44
# Dependencies for CPUs
5-
torch==2.6.0+cpu; platform_machine == "x86_64"
6-
torch==2.6.0; platform_system == "Darwin"
7-
torch==2.6.0; platform_machine == "ppc64le" or platform_machine == "aarch64"
8-
torch==2.7.0.dev20250304; platform_machine == "s390x"
5+
packaging>=24.2
6+
setuptools>=77.0.3,<80.0.0
7+
--extra-index-url https://download.pytorch.org/whl/cpu
8+
torch==2.7.0+cpu; platform_machine == "x86_64"
9+
torch==2.7.0; platform_system == "Darwin"
10+
torch==2.7.0; platform_machine == "ppc64le" or platform_machine == "aarch64"
911

1012
# required for the image processor of minicpm-o-2_6, this must be updated alongside torch
1113
torchaudio; platform_machine != "ppc64le" and platform_machine != "s390x"

0 commit comments

Comments
 (0)