@@ -25,17 +25,32 @@ set -euo pipefail
2525EXTRACT=" ${1:? usage: setup_env.sh <dir containing TensorRT-LLM/ (wheel)>} "
2626PYTHON=" ${PYTHON:- python3} "
2727
28+ # BOLT_SETUP_LIBS_ONLY=1: the caller only needs the wheel's ELF .so files ON DISK
29+ # (e.g. the merge job reconstructs the pre-instrument originals to convert
30+ # .fdata -> .yaml -- see internal/slurm_merge.sh). That path never imports
31+ # tensorrt / tensorrt_llm at runtime (library discovery uses
32+ # importlib.util.find_spec, which does NOT execute the package), so the
33+ # runtime-tensorrt gate below is irrelevant and would spuriously fail on a
34+ # profiling base image whose `import tensorrt` isn't wired up before install.
35+ # Skip the import checks in that mode but still install the wheel (--no-deps).
36+ LIBS_ONLY=" ${BOLT_SETUP_LIBS_ONLY:- 0} "
37+
2838WHEEL=$( ls " $EXTRACT " /TensorRT-LLM/tensorrt_llm-* .whl 2> /dev/null | head -1 || true)
2939[[ -f " $WHEEL " ]] || { echo " [ERROR] No tensorrt_llm wheel under $EXTRACT /TensorRT-LLM/" ; exit 1; }
3040
3141# 0. The container must already have a working tensorrt (runtime-capable image).
32- if ! " $PYTHON " -c " import tensorrt" 2> /dev/null; then
33- echo " [ERROR] 'import tensorrt' fails in this container BEFORE install." >&2
34- echo " Use a runtime-capable image (devel/release) with TensorRT intact;" >&2
35- echo " a bare CUDA/pytorch base or an image with a stripped tensorrt will not work." >&2
36- exit 1
42+ # Skipped in libs-only mode (no runtime import happens downstream).
43+ if [[ " $LIBS_ONLY " != " 1" ]]; then
44+ if ! " $PYTHON " -c " import tensorrt" 2> /dev/null; then
45+ echo " [ERROR] 'import tensorrt' fails in this container BEFORE install." >&2
46+ echo " Use a runtime-capable image (devel/release) with TensorRT intact;" >&2
47+ echo " a bare CUDA/pytorch base or an image with a stripped tensorrt will not work." >&2
48+ exit 1
49+ fi
50+ echo " [INFO] tensorrt OK: $( " $PYTHON " -c ' import tensorrt; print(tensorrt.__version__)' ) "
51+ else
52+ echo " [INFO] BOLT_SETUP_LIBS_ONLY=1: skipping runtime tensorrt import checks (libs-only)."
3753fi
38- echo " [INFO] tensorrt OK: $( " $PYTHON " -c ' import tensorrt; print(tensorrt.__version__)' ) "
3954
4055# 1. Wheel WITHOUT deps -> never touches tensorrt. --force-reinstall so the BOLT
4156# libs overlay any preinstalled trtllm (release image).
@@ -44,5 +59,9 @@ pip install --no-deps --force-reinstall "$WHEEL"
4459
4560# 2. Verify from a neutral cwd so the extracted source tree doesn't shadow the
4661# installed package (a source `tensorrt_llm/` has no compiled bindings).
47- ( cd /tmp && " $PYTHON " -c " import tensorrt, tensorrt_llm; print('[INFO] runtime + trtllm ok:', tensorrt_llm.__file__)" )
62+ # Skipped in libs-only mode: only the on-disk .so files are needed, and the
63+ # runtime import may legitimately fail on a libs-only base image.
64+ if [[ " $LIBS_ONLY " != " 1" ]]; then
65+ ( cd /tmp && " $PYTHON " -c " import tensorrt, tensorrt_llm; print('[INFO] runtime + trtllm ok:', tensorrt_llm.__file__)" )
66+ fi
4867echo " [SUCCESS] Environment ready for BOLT flow."
0 commit comments