Skip to content

Commit b0d4612

Browse files
authored
Use post build function for TRT-LLM backend (#6476)
* Use postbuild function * Remove updating submodule url
1 parent d33eaa5 commit b0d4612

File tree

1 file changed

+9
-58
lines changed

1 file changed

+9
-58
lines changed

build.py

+9-58
Original file line numberDiff line numberDiff line change
@@ -1305,54 +1305,17 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
13051305
# Add dependencies needed for tensorrtllm backend
13061306
if "tensorrtllm" in backends:
13071307
be = "tensorrtllm"
1308-
# url = "https://raw.githubusercontent.com/triton-inference-server/tensorrtllm_backend/{}/tools/gen_trtllm_dockerfile.py".format(
1309-
# backends[be]
1310-
# )
1311-
1312-
# response = requests.get(url)
1313-
# spec = importlib.util.spec_from_loader(
1314-
# "trtllm_buildscript", loader=None, origin=url
1315-
# )
1316-
# trtllm_buildscript = importlib.util.module_from_spec(spec)
1317-
# exec(response.content, trtllm_buildscript.__dict__)
1318-
# df += trtllm_buildscript.create_postbuild(backends[be])
1319-
1320-
df += """
1321-
WORKDIR /workspace
1322-
# Remove previous TRT installation
1323-
RUN apt-get remove --purge -y tensorrt* libnvinfer*
1324-
RUN pip uninstall -y tensorrt
1325-
# Install new version of TRT using the script from TRT-LLM
1326-
RUN apt-get update && apt-get install -y --no-install-recommends python-is-python3
1327-
RUN git clone --single-branch --depth=1 -b {} https://github.com/triton-inference-server/tensorrtllm_backend.git tensorrtllm_backend
1328-
RUN cd tensorrtllm_backend && git submodule set-url -- tensorrt_llm https://github.com/NVIDIA/TensorRT-LLM.git
1329-
RUN cd tensorrtllm_backend && git submodule sync
1330-
RUN cd tensorrtllm_backend && git submodule update --init --recursive
1331-
RUN cp tensorrtllm_backend/tensorrt_llm/docker/common/install_tensorrt.sh /tmp/
1332-
RUN rm -fr tensorrtllm_backend
1333-
""".format(
1308+
url = "https://raw.githubusercontent.com/triton-inference-server/tensorrtllm_backend/{}/tools/gen_trtllm_dockerfile.py".format(
13341309
backends[be]
13351310
)
13361311

1337-
df += """
1338-
RUN bash /tmp/install_tensorrt.sh && rm /tmp/install_tensorrt.sh
1339-
ENV TRT_ROOT=/usr/local/tensorrt
1340-
# Remove TRT contents that are not needed in runtime
1341-
RUN ARCH="$(uname -i)" && \
1342-
rm -fr ${TRT_ROOT}/bin ${TRT_ROOT}/targets/${ARCH}-linux-gnu/bin ${TRT_ROOT}/data && \
1343-
rm -fr ${TRT_ROOT}/doc ${TRT_ROOT}/onnx_graphsurgeon ${TRT_ROOT}/python && \
1344-
rm -fr ${TRT_ROOT}/samples ${TRT_ROOT}/targets/${ARCH}-linux-gnu/samples
1345-
# Install required packages for TRT-LLM models
1346-
RUN python3 -m pip install --upgrade pip && \
1347-
pip3 install transformers && \
1348-
pip3 install torch
1349-
# Uninstall unused nvidia packages
1350-
RUN if pip freeze | grep -q "nvidia.*"; then \
1351-
pip freeze | grep "nvidia.*" | xargs pip uninstall -y; \
1352-
fi
1353-
RUN pip cache purge
1354-
ENV LD_LIBRARY_PATH=/usr/local/tensorrt/lib/:/opt/tritonserver/backends/tensorrtllm:$LD_LIBRARY_PATH
1355-
"""
1312+
response = requests.get(url)
1313+
spec = importlib.util.spec_from_loader(
1314+
"trtllm_buildscript", loader=None, origin=url
1315+
)
1316+
trtllm_buildscript = importlib.util.module_from_spec(spec)
1317+
exec(response.content, trtllm_buildscript.__dict__)
1318+
df += trtllm_buildscript.create_postbuild(backends[be])
13561319

13571320
if "vllm" in backends:
13581321
# [DLIS-5606] Build Conda environment for vLLM backend
@@ -1843,22 +1806,10 @@ def backend_build(
18431806
cmake_script.comment()
18441807
cmake_script.mkdir(build_dir)
18451808
cmake_script.cwd(build_dir)
1809+
cmake_script.gitclone(backend_repo(be), tag, be, github_organization)
18461810

18471811
if be == "tensorrtllm":
1848-
cmake_script.cmd(
1849-
"git clone --single-branch --depth=1 -b {} https://github.com/triton-inference-server/tensorrtllm_backend tensorrtllm".format(
1850-
tag
1851-
)
1852-
)
1853-
cmake_script.cmd("cd tensorrtllm")
1854-
cmake_script.cmd(
1855-
"git submodule set-url -- tensorrt_llm https://github.com/NVIDIA/TensorRT-LLM.git"
1856-
)
1857-
cmake_script.cmd("git submodule sync")
1858-
cmake_script.cmd("cd ..")
18591812
tensorrtllm_prebuild(cmake_script)
1860-
else:
1861-
cmake_script.gitclone(backend_repo(be), tag, be, github_organization)
18621813

18631814
cmake_script.mkdir(repo_build_dir)
18641815
cmake_script.cwd(repo_build_dir)

0 commit comments

Comments
 (0)