@@ -18,10 +18,7 @@ ARG BASH_ENV="/etc/bash.bashrc"
1818ENV BASH_ENV=${BASH_ENV}
1919
2020ARG GITHUB_MIRROR=""
21- RUN echo "Using GitHub mirror: $GITHUB_MIRROR"
22-
2321ARG PYTHON_VERSION="3.12.3"
24- RUN echo "Using Python version: $PYTHON_VERSION"
2522
2623SHELL ["/bin/bash", "-c"]
2724
@@ -31,62 +28,36 @@ FROM base AS devel
3128# NB: PyTorch requires this to be < 1.0
3229ENV PYTORCH_ALLOC_CONF="garbage_collection_threshold:0.99999"
3330
34- # Copy all installation scripts at once to reduce layers
35- COPY docker/common/install.sh \
36- docker/common/install_base.sh \
37- docker/common/install_cmake.sh \
38- docker/common/install_ccache.sh \
39- docker/common/install_cuda_toolkit.sh \
40- docker/common/install_tensorrt.sh \
41- docker/common/install_polygraphy.sh \
42- docker/common/install_mpi4py.sh \
43- docker/common/install_pytorch.sh \
44- docker/common/install_ucx.sh \
45- docker/common/install_nixl.sh \
46- docker/common/install_etcd.sh \
47- ./
48-
4931ARG TRT_VER
5032ARG CUDA_VER
5133ARG CUDNN_VER
5234ARG NCCL_VER
5335ARG CUBLAS_VER
5436ARG TORCH_INSTALL_TYPE="skip"
55- RUN GITHUB_MIRROR=${GITHUB_MIRROR} \
37+ RUN --mount=type=cache,target=/root/.cache/pip \
38+ --mount=source=docker/common,target=/tmp/docker/common \
39+ --mount=source=constraints.txt,target=/tmp/constraints.txt \
40+ GITHUB_MIRROR=${GITHUB_MIRROR} \
5641 PYTHON_VERSION=${PYTHON_VERSION} \
5742 TRT_VER=${TRT_VER} \
5843 CUDA_VER=${CUDA_VER} \
5944 CUDNN_VER=${CUDNN_VER} \
6045 NCCL_VER=${NCCL_VER} \
6146 CUBLAS_VER=${CUBLAS_VER} \
6247 TORCH_INSTALL_TYPE=${TORCH_INSTALL_TYPE} \
63- bash ./install.sh --base --cmake --ccache --cuda_toolkit --tensorrt --polygraphy --mpi4py --pytorch --opencv && \
64- rm install_base.sh && \
65- rm install_cmake.sh && \
66- rm install_ccache.sh && \
67- rm install_cuda_toolkit.sh && \
68- rm install_tensorrt.sh && \
69- rm install_polygraphy.sh && \
70- rm install_mpi4py.sh && \
71- rm install_pytorch.sh && \
72- rm install.sh
73-
74- # Copy and install dependencies from constraints.txt
75- COPY constraints.txt /tmp/constraints.txt
76- RUN pip3 install --no-cache-dir -r /tmp/constraints.txt && rm /tmp/constraints.txt
77-
78- # Remove nbconvert to avoid https://github.com/advisories/GHSA-xm59-rqc7-hhvf in the base NGC PyTorch image.
79- RUN pip3 uninstall -y nbconvert || true
48+ echo "Using GitHub mirror: $GITHUB_MIRROR" && \
49+ echo "Using Python version: $PYTHON_VERSION" && \
50+ bash /tmp/docker/common/install.sh --base --cmake --ccache --cuda_toolkit --tensorrt --polygraphy --mpi4py --pytorch --opencv && \
51+ pip3 install --no-cache-dir -r /tmp/constraints.txt && \
52+ # Remove nbconvert to avoid https://github.com/advisories/GHSA-xm59-rqc7-hhvf in the base NGC PyTorch image.
53+ (pip3 uninstall -y nbconvert || true)
8054
8155# Install UCX, NIXL, etcd
82- # TODO: Combine these into the main install.sh script
83- RUN GITHUB_MIRROR=${GITHUB_MIRROR} bash ./install_ucx.sh && \
84- GITHUB_MIRROR=${GITHUB_MIRROR} bash ./install_nixl.sh && \
85- bash ./install_etcd.sh && \
86- rm install_ucx.sh && \
87- rm install_nixl.sh && \
88- rm install_etcd.sh && \
89- rm -rf /root/.cache/pip && \
56+ RUN --mount=type=cache,target=/root/.cache/pip \
57+ --mount=source=docker/common,target=/tmp/docker/common \
58+ GITHUB_MIRROR=${GITHUB_MIRROR} bash /tmp/docker/common/install_ucx.sh && \
59+ GITHUB_MIRROR=${GITHUB_MIRROR} bash /tmp/docker/common/install_nixl.sh && \
60+ bash /tmp/docker/common/install_etcd.sh && \
9061 rm -rf /root/.cache/uv/archive-v0 && \
9162 # WAR against https://github.com/advisories/GHSA-58pv-8j8x-9vj2
9263 rm -rf /usr/local/lib/python3.12/dist-packages/setuptools/_vendor/jaraco.context-5.3.0.dist-info && \
@@ -96,9 +67,8 @@ RUN GITHUB_MIRROR=${GITHUB_MIRROR} bash ./install_ucx.sh && \
9667# Generate OSS attribution file for devel image
9768ARG TRT_LLM_VER
9869ARG TARGETARCH
99- COPY scripts/generate_container_oss_attribution.sh /tmp/generate_container_oss_attribution.sh
100- RUN bash /tmp/generate_container_oss_attribution.sh "devel" "${TRT_LLM_VER}" "${TARGETARCH}" && \
101- rm /tmp/generate_container_oss_attribution.sh
70+ RUN --mount=source=scripts/generate_container_oss_attribution.sh,target=/tmp/generate_container_oss_attribution.sh \
71+ bash /tmp/generate_container_oss_attribution.sh "devel" "${TRT_LLM_VER}" "${TARGETARCH}"
10272
10373FROM ${TRITON_IMAGE}:${TRITON_BASE_TAG} AS triton
10474
@@ -111,20 +81,14 @@ COPY --from=triton /opt/tritonserver/include /opt/tritonserver/include
11181COPY --from=triton /opt/tritonserver/bin /opt/tritonserver/bin
11282COPY --from=triton /opt/tritonserver/caches /opt/tritonserver/caches
11383
114- # Copy all installation scripts at once to reduce layers
115- COPY docker/common/install_triton.sh \
116- docker/common/install_mooncake.sh \
117- ./
118-
119- # Install Mooncake, after triton handles boost requirement
120- RUN GITHUB_MIRROR=${GITHUB_MIRROR} bash ./install_triton.sh && \
84+ # Install Triton and Mooncake
85+ RUN --mount=source=docker/common,target=/tmp/docker/common \
86+ GITHUB_MIRROR=${GITHUB_MIRROR} bash /tmp/docker/common/install_triton.sh && \
12187 if [ -f /etc/redhat-release ]; then \
12288 echo "Rocky8 detected, skipping mooncake installation"; \
12389 else \
124- bash ./install_mooncake.sh; \
125- fi && \
126- rm install_triton.sh && \
127- rm install_mooncake.sh
90+ bash /tmp/docker/common/install_mooncake.sh; \
91+ fi
12892
12993FROM ${DEVEL_IMAGE} AS wheel
13094WORKDIR /src/tensorrt_llm
@@ -148,43 +112,45 @@ RUN --mount=type=cache,target=/root/.cache/pip --mount=type=cache,target=${CCACH
148112
149113FROM ${DEVEL_IMAGE} AS release
150114
151- # Create a cache directory for pip
152- RUN mkdir -p /root/.cache/pip
153-
154115WORKDIR /app/tensorrt_llm
155116RUN --mount=type=cache,target=/root/.cache/pip --mount=type=bind,from=wheel,source=/src/tensorrt_llm/build,target=/tmp/wheel \
156117 pip install /tmp/wheel/tensorrt_llm*.whl
157118
158- COPY README.md ./
159- COPY --from=wheel /src/tensorrt_llm/build/tensorrt_llm*.whl ./
160- COPY docs docs
161- COPY cpp/include include
162-
163- RUN ln -sv $(python3 -c 'import site; print(f"{site.getsitepackages()[0]}/tensorrt_llm/bin")') bin && \
164- test -f bin/executorWorker && \
165- ln -sv $(python3 -c 'import site; print(f"{site.getsitepackages()[0]}/tensorrt_llm/libs")') lib && \
166- test -f lib/libnvinfer_plugin_tensorrt_llm.so && \
167- echo "/app/tensorrt_llm/lib" > /etc/ld.so.conf.d/tensorrt_llm.conf && \
168- ldconfig && \
169- ! ( ldd -v bin/executorWorker | grep tensorrt_llm | grep -q "not found" )
170-
171- ARG SRC_DIR=/src/tensorrt_llm
172- COPY --from=wheel ${SRC_DIR}/benchmarks benchmarks
173- ARG CPP_BUILD_DIR=${SRC_DIR}/cpp/build
174- COPY --from=wheel \
175- ${CPP_BUILD_DIR}/benchmarks/bertBenchmark \
176- ${CPP_BUILD_DIR}/benchmarks/gptManagerBenchmark \
177- ${CPP_BUILD_DIR}/benchmarks/disaggServerBenchmark \
178- benchmarks/cpp/
179-
180- COPY examples examples
181- RUN chmod -R a+w examples && \
119+ RUN --mount=source=README.md,target=/tmp/ctx/README.md \
120+ --mount=source=docs,target=/tmp/ctx/docs \
121+ --mount=source=cpp/include,target=/tmp/ctx/include \
122+ --mount=source=examples,target=/tmp/ctx/examples \
123+ --mount=type=bind,from=wheel,source=/src/tensorrt_llm/build,target=/tmp/wheel \
124+ --mount=type=bind,from=wheel,source=/src/tensorrt_llm/benchmarks,target=/tmp/benchmarks \
125+ --mount=type=bind,from=wheel,source=/src/tensorrt_llm/cpp/build/benchmarks,target=/tmp/cpp_benchmarks \
126+ # Copy build context files
127+ cp /tmp/ctx/README.md ./ && \
128+ cp -r /tmp/ctx/docs ./docs && \
129+ cp -r /tmp/ctx/include ./include && \
130+ cp -r /tmp/ctx/examples ./examples && \
131+ chmod -R a+w examples && \
132+ # Copy wheel stage outputs
133+ cp /tmp/wheel/tensorrt_llm*.whl ./ && \
134+ cp -r /tmp/benchmarks ./benchmarks && \
135+ mkdir -p benchmarks/cpp && \
136+ cp /tmp/cpp_benchmarks/bertBenchmark \
137+ /tmp/cpp_benchmarks/gptManagerBenchmark \
138+ /tmp/cpp_benchmarks/disaggServerBenchmark \
139+ benchmarks/cpp/ && \
182140 rm -v \
183141 benchmarks/cpp/bertBenchmark.cpp \
184142 benchmarks/cpp/gptManagerBenchmark.cpp \
185143 benchmarks/cpp/disaggServerBenchmark.cpp \
186144 benchmarks/cpp/CMakeLists.txt && \
187- rm -rf /root/.cache/pip && \
145+ # Create symlinks to installed package binaries and libraries
146+ ln -sv $(python3 -c 'import site; print(f"{site.getsitepackages()[0]}/tensorrt_llm/bin")') bin && \
147+ test -f bin/executorWorker && \
148+ ln -sv $(python3 -c 'import site; print(f"{site.getsitepackages()[0]}/tensorrt_llm/libs")') lib && \
149+ test -f lib/libnvinfer_plugin_tensorrt_llm.so && \
150+ echo "/app/tensorrt_llm/lib" > /etc/ld.so.conf.d/tensorrt_llm.conf && \
151+ ldconfig && \
152+ ! ( ldd -v bin/executorWorker | grep tensorrt_llm | grep -q "not found" ) && \
153+ # Clean up uv cache and CVE workarounds
188154 rm -rf /root/.cache/uv/archive-v0 && \
189155 # WAR against https://github.com/advisories/GHSA-58pv-8j8x-9vj2
190156 rm -rf /usr/local/lib/python3.12/dist-packages/setuptools/_vendor/jaraco.context-5.3.0.dist-info && \
@@ -198,8 +164,8 @@ ENV TRT_LLM_GIT_COMMIT=${GIT_COMMIT} \
198164 TRT_LLM_VERSION=${TRT_LLM_VER}
199165
200166# Generate OSS attribution file for release image
201- COPY scripts/generate_container_oss_attribution.sh /tmp/generate_container_oss_attribution.sh
202- RUN bash /tmp/generate_container_oss_attribution.sh "release" "${TRT_LLM_VER}" "${TARGETARCH}" && rm /tmp/generate_container_oss_attribution.sh
167+ RUN --mount=source= scripts/generate_container_oss_attribution.sh,target= /tmp/generate_container_oss_attribution.sh \
168+ bash /tmp/generate_container_oss_attribution.sh "release" "${TRT_LLM_VER}" "${TARGETARCH}"
203169
204170FROM wheel AS tritonbuild
205171
0 commit comments