22# builder
33ARG BASE_IMAGE=nvcr.io/nvidia/pytorch:25.03-py3
44
5- # # build args
5+ # # build base env
66FROM ${BASE_IMAGE} AS setup_env
77
8- ARG TORCH_VERSION
98ARG PPA_SOURCE
10-
11- RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
12- sed -i "s@http://.*.ubuntu.com@${PPA_SOURCE}@g" /etc/apt/sources.list.d/ubuntu.sources && \
9+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
10+ RUN sed -i "s@http://.*.ubuntu.com@${PPA_SOURCE}@g" /etc/apt/sources.list.d/ubuntu.sources && \
1311 apt update && \
1412 apt install --no-install-recommends ca-certificates -y && \
1513 apt install --no-install-recommends bc wget -y && \
1614 apt install --no-install-recommends build-essential sudo -y && \
1715 apt install --no-install-recommends git curl pkg-config tree unzip tmux \
1816 openssh-server openssh-client dnsutils iproute2 lsof net-tools zsh rclone \
19- iputils-ping telnet netcat-openbsd -y && \
17+ iputils-ping telnet netcat-openbsd htop bubblewrap socat -y && \
2018 apt clean && rm -rf /var/lib/apt/lists/*
2119
2220RUN if [ -d /etc/pip ] && [ -f /etc/pip/constraint.txt ]; then echo > /etc/pip/constraint.txt; fi
23- RUN pip install pystack py-spy --no-cache-dir
21+ RUN pip uninstall flash_attn opencv -y && rm -rf /usr/local/lib/python3.12/dist-packages/cv2
2422RUN git config --system --add safe.directory "*"
2523
24+ # torch
25+ ARG TORCH_VERSION
26+ ARG PYTORCH_WHEELS_URL
2627RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
28+ --mount=type=secret,id=NO_PROXY,env=no_proxy \
2729 if [ -n "${TORCH_VERSION}" ]; then \
2830 pip install torchvision torch==${TORCH_VERSION} \
29- --index-url https://download.pytorch.org/whl /cu128 \
30- --extra-index-url https://download.pytorch.org/whl /cu126 \
31+ -i ${PYTORCH_WHEELS_URL} /cu128 \
32+ --extra-index-url ${PYTORCH_WHEELS_URL} /cu126 \
3133 --no-cache-dir; \
3234 fi
33-
3435# set reasonable default for CUDA architectures when building ngc image
35- ENV TORCH_CUDA_ARCH_LIST="7.5 8.0 8.6 9.0 10.0"
36-
37- RUN pip uninstall flash_attn opencv -y && rm -rf /usr/local/lib/python3.12/dist-packages/cv2
36+ ENV TORCH_CUDA_ARCH_LIST="9.0 10.0"
3837
3938ARG FLASH_ATTN_DIR=/tmp/flash-attn
4039ARG CODESPACE=/root/codespace
@@ -56,6 +55,9 @@ ARG CODESPACE
5655ARG FLASH_ATTN_DIR
5756ARG FLASH_ATTN3_DIR
5857ARG FLASH_ATTN_URL
58+ # force hopper for now, you change it throught build args
59+ ARG FLASH_ATTN_CUDA_ARCHS="90"
60+ ARG FLASH_ATTENTION_DISABLE_SM80="TRUE"
5961
6062RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
6163 git clone $(echo ${FLASH_ATTN_URL} | cut -d '@' -f 1) && \
@@ -119,42 +121,41 @@ WORKDIR ${CODESPACE}/causal-conv1d
119121
120122RUN CAUSAL_CONV1D_FORCE_BUILD=TRUE pip wheel -w ${CAUSAL_CONV1D_DIR} -v --no-deps --no-build-isolation .
121123
122- # pypi install nvshmem and compile deepep
124+ # compile nvshmem and deepep
123125FROM setup_env AS deep_ep
124126
125127ARG CODESPACE
126128ARG DEEP_EP_DIR
127129ARG DEEP_EP_URL
128- # build sm90 and sm100 for deep_ep for now
129- ARG TORCH_CUDA_ARCH_LIST="9.0 10.0"
130130
131+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
132+ # curl -LO https://github.com/NVIDIA/nvshmem/releases/download/v3.4.5-0/nvshmem_src_cuda-all-all-3.4.5.tar.gz && \
133+ # tar -zxvf nvshmem_src_cuda-all-all-3.4.5.tar.gz && \
134+ # cd ${CODESPACE}/nvshmem_src && \
135+ # NVSHMEM_SHMEM_SUPPORT=0 \
136+ # NVSHMEM_UCX_SUPPORT=0 \
137+ # NVSHMEM_USE_NCCL=0 \
138+ # NVSHMEM_MPI_SUPPORT=0 \
139+ # NVSHMEM_IBGDA_SUPPORT=1 \
140+ # NVSHMEM_USE_GDRCOPY=0 \
141+ # NVSHMEM_PMIX_SUPPORT=0 \
142+ # NVSHMEM_TIMEOUT_DEVICE_POLLING=0 \
143+ # NVSHMEM_BUILD_TESTS=0 \
144+ # NVSHMEM_BUILD_EXAMPLES=0 \
145+ # NVSHMEM_BUILD_HYDRA_LAUNCHER=0 \
146+ # NVSHMEM_BUILD_TXZ_PACKAGE=0 \
147+ # NVSHMEM_BUILD_PYTHON_LIB=OFF \
148+ # cmake -S . -B build/ -DCMAKE_INSTALL_PREFIX=${NVSHMEM_PREFIX} -DMLX5_lib=/lib/x86_64-linux-gnu/libmlx5.so.1 && \
149+ # cmake --build build --target install --parallel 32 && \
131150RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
132- curl -LO https://github.com/NVIDIA/nvshmem/releases/download/v3.4.5-0/nvshmem_src_cuda-all-all-3.4.5.tar.gz && \
133- tar -zxvf nvshmem_src_cuda-all-all-3.4.5.tar.gz && \
134- cd ${CODESPACE}/nvshmem_src && \
135- NVSHMEM_SHMEM_SUPPORT=0 \
136- NVSHMEM_UCX_SUPPORT=0 \
137- NVSHMEM_USE_NCCL=0 \
138- NVSHMEM_MPI_SUPPORT=0 \
139- NVSHMEM_IBGDA_SUPPORT=1 \
140- NVSHMEM_USE_GDRCOPY=0 \
141- NVSHMEM_PMIX_SUPPORT=0 \
142- NVSHMEM_TIMEOUT_DEVICE_POLLING=0 \
143- NVSHMEM_BUILD_TESTS=0 \
144- NVSHMEM_BUILD_EXAMPLES=0 \
145- NVSHMEM_BUILD_HYDRA_LAUNCHER=0 \
146- NVSHMEM_BUILD_TXZ_PACKAGE=0 \
147- NVSHMEM_BUILD_PYTHON_LIB=OFF \
148- cmake -S . -B build/ -DCMAKE_INSTALL_PREFIX=${NVSHMEM_PREFIX} -DMLX5_lib=/lib/x86_64-linux-gnu/libmlx5.so.1 && \
149- cmake --build build --target install --parallel 32 && \
150151 cd ${CODESPACE} && git clone $(echo ${DEEP_EP_URL} | cut -d '@' -f 1) && \
151152 cd ${CODESPACE}/DeepEP && \
152153 git checkout $(echo ${DEEP_EP_URL} | cut -d '@' -f 2) && \
153154 git submodule update --init --recursive --force
154155
155156WORKDIR ${CODESPACE}/DeepEP
156157
157- RUN NVSHMEM_DIR=${NVSHMEM_PREFIX} pip wheel -w ${DEEP_EP_DIR} -v --no-deps .
158+ RUN pip wheel -w ${DEEP_EP_DIR} -v --no-deps .
158159
159160# compile deep_gemm
160161FROM setup_env AS deep_gemm
@@ -192,7 +193,7 @@ COPY --from=flash_attn ${FLASH_ATTN_DIR} ${FLASH_ATTN_DIR}
192193COPY --from=adaptive_gemm ${ADAPTIVE_GEMM_DIR} ${ADAPTIVE_GEMM_DIR}
193194COPY --from=grouped_gemm ${GROUPED_GEMM_DIR} ${GROUPED_GEMM_DIR}
194195COPY --from=deep_ep ${DEEP_EP_DIR} ${DEEP_EP_DIR}
195- COPY --from=deep_ep ${NVSHMEM_PREFIX} ${NVSHMEM_PREFIX}
196+ # COPY --from=deep_ep ${NVSHMEM_PREFIX} ${NVSHMEM_PREFIX}
196197COPY --from=deep_gemm ${DEEP_GEMM_DIR} ${DEEP_GEMM_DIR}
197198COPY --from=causal_conv1d ${CAUSAL_CONV1D_DIR} ${CAUSAL_CONV1D_DIR}
198199
@@ -204,11 +205,16 @@ RUN unzip ${DEEP_EP_DIR}/*.whl -d ${PYTHON_SITE_PACKAGE_PATH}
204205RUN unzip ${DEEP_GEMM_DIR}/*.whl -d ${PYTHON_SITE_PACKAGE_PATH}
205206RUN unzip ${CAUSAL_CONV1D_DIR}/*.whl -d ${PYTHON_SITE_PACKAGE_PATH}
206207
207- # install sglang and its runtime requirements
208+ ARG DEFAULT_PYPI_URL
209+
210+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
211+ RUN pip install pystack py-spy --no-cache-dir -i ${DEFAULT_PYPI_URL}
208212
213+ # install sglang and its runtime requirements
209214ENV XTUNER_SGLANG_ENVS_DIR=/envs/sglang
210215
211- RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
216+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
217+ RUN \
212218 pip install --target ${XTUNER_SGLANG_ENVS_DIR} \
213219 sglang==0.5.9 sgl-kernel==0.3.21 \
214220 apache-tvm-ffi==0.1.9 \
@@ -229,7 +235,7 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
229235 torchao==0.9.0 \
230236 torchaudio==2.9.1 \
231237 torchcodec==0.8.0 \
232- xgrammar==0.1.27 \
238+ xgrammar==0.1.32 \
233239 smg-grpc-proto==0.4.5 \
234240 grpcio==1.78.1 \
235241 grpcio-reflection==1.78.1 \
@@ -250,54 +256,60 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
250256 llguidance==0.7.11 blobfile==3.0.0 \
251257 pybase64 orjson uvloop setproctitle msgspec \
252258 compressed_tensors python-multipart \
253- hf_transfer interegular --no-cache-dir --no-deps
259+ hf_transfer interegular --no-cache-dir --no-deps -i ${DEFAULT_PYPI_URL}
254260
255261# install lmdeploy and its missing runtime requirements
256262ARG LMDEPLOY_VERSION
257263ARG LMDEPLOY_URL
258264ENV XTUNER_LMDEPLOY_ENVS_DIR=/envs/lmdeploy
259265
266+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
267+ ARG LMDEPLOY_WHEELS=https://github.com/InternLM/lmdeploy/releases/download/v${LMDEPLOY_VERSION}/lmdeploy-${LMDEPLOY_VERSION}+cu128-cp312-cp312-manylinux2014_x86_64.whl
260268RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
269+ --mount=type=secret,id=NO_PROXY,env=no_proxy \
261270 pip install fastapi fire openai outlines \
262- partial_json_parser ray[default] shortuuid uvicorn \
263- 'pydantic>2' openai_harmony dlblas --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-cache-dir && \
271+ partial_json_parser ' ray[default]<3' shortuuid uvicorn \
272+ 'pydantic>2' openai_harmony dlblas --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-cache-dir -i ${DEFAULT_PYPI_URL} && \
264273 if [ -n "${LMDEPLOY_VERSION}" ]; then \
265- pip install lmdeploy==${LMDEPLOY_VERSION} --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-deps --no-cache-dir; \
274+ # pip install lmdeploy==${LMDEPLOY_VERSION} --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-deps --no-cache-dir -i ${DEFAULT_PYPI_URL}; \
275+ echo pip install ${LMDEPLOY_WHEELS} --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-deps --no-cache-dir -i ${DEFAULT_PYPI_URL}; \
276+ pip install ${LMDEPLOY_WHEELS} --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-deps --no-cache-dir -i ${DEFAULT_PYPI_URL}; \
266277 else \
267278 git clone $(echo ${LMDEPLOY_URL} | cut -d '@' -f 1) && \
268279 cd ${CODESPACE}/lmdeploy && \
269280 git checkout $(echo ${LMDEPLOY_URL} | cut -d '@' -f 2) && \
270- pip install . -v --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-deps --no-cache-dir; \
281+ pip install . -v --target ${XTUNER_LMDEPLOY_ENVS_DIR} --no-deps --no-cache-dir -i ${DEFAULT_PYPI_URL} ; \
271282 fi
272283
273284# # install xtuner
274285ARG XTUNER_URL
275286ARG XTUNER_COMMIT
276- # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
287+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
277288# git clone $(echo ${XTUNER_URL} | cut -d '@' -f 1) && \
278289# cd ${CODESPACE}/xtuner && \
279290# git checkout $(echo ${XTUNER_URL} | cut -d '@' -f 2)
280291COPY . ${CODESPACE}/xtuner
281292
282293WORKDIR ${CODESPACE}/xtuner
283- RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
284- pip install .[all] -v --no-cache-dir
285294
286295# Install custom .pth file for conditional lmdeploy and sglang path injection
287296RUN cp .dev_scripts/xtuner_rl_path.pth ${PYTHON_SITE_PACKAGE_PATH}/xtuner_rl_path.pth
288297
298+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
299+ RUN pip install .[all] -v --no-cache-dir -i ${DEFAULT_PYPI_URL}
300+
289301WORKDIR ${CODESPACE}
290302
291303# nccl update for torch 2.6.0
292- RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
293- if [ "x${TORCH_VERSION}" = "x2.6.0" ]; then \
294- pip install nvidia-nccl-cu12==2.25.1 --no-cache-dir; \
304+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
305+ RUN if [ "x${TORCH_VERSION}" = "x2.6.0" ]; then \
306+ pip install nvidia-nccl-cu12==2.25.1 --no-cache-dir -i ${DEFAULT_PYPI_URL} ; \
295307 fi
296308
297309# cudnn update for torch 2.9.1
298- RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
299- if [ "x${TORCH_VERSION}" = "x2.9.1" ]; then \
300- pip install nvidia-cudnn-cu12==9.15.1.9 --no-cache-dir; \
310+ # RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
311+ RUN if [ "x${TORCH_VERSION}" = "x2.9.1" ]; then \
312+ pip install nvidia-cudnn-cu12==9.15.1.9 --no-cache-dir -i ${DEFAULT_PYPI_URL} ; \
301313 fi
302314
303315# setup sysctl
0 commit comments