@@ -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+
87109FROM python-install AS torch-vision
88110# Install torchvision
89- ARG TORCH_VERSION=2.7.0.dev20250304
111+ ARG TORCH_VERSION=2.7.0
90112ARG TORCH_VISION_VERSION=v0.20.1
91113WORKDIR /tmp
92114RUN --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
99123FROM 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
0 commit comments