Skip to content

Commit 78fac1f

Browse files
yiqingy0chzblych
andauthored
[None][chore] Lock onnx version <1.20.0 and remove WAR for TRT 10.13 (#9006)
Signed-off-by: Yiqing Yan <[email protected]> Signed-off-by: Yanchao Lu <[email protected]> Co-authored-by: Yanchao Lu <[email protected]>
1 parent 67af7c1 commit 78fac1f

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

docs/source/installation/linux.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,15 @@ There are some known limitations when you pip install pre-built TensorRT LLM whe
5959
when OMPI was not configured --with-slurm and we weren't able
6060
to discover a SLURM installation in the usual places.
6161
```
62+
63+
2. Prevent `pip` from replacing existing PyTorch installation
64+
65+
On certain systems, particularly Ubuntu 22.04, users installing TensorRT LLM would find that their existing, CUDA 13.0 compatible PyTorch installation (e.g., `torch==2.9.0+cu130`) was being uninstalled by `pip`. It was then replaced by a CUDA 12.8 version (`torch==2.9.0`), causing the TensorRT LLM installation to be unusable and leading to runtime errors.
66+
67+
The solution is to create a `pip` constraints file, locking `torch` to the currently installed version. Here is an example of how this can be done manually:
68+
69+
```bash
70+
CURRENT_TORCH_VERSION=$(python3 -c "import torch; print(torch.__version__)")
71+
echo "torch==$CURRENT_TORCH_VERSION" > /tmp/torch-constraint.txt
72+
pip3 install --upgrade pip setuptools && pip3 install tensorrt_llm -c /tmp/torch-constraint.txt
73+
```

requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ diffusers>=0.27.0
88
lark
99
mpi4py
1010
numpy<2
11-
onnx>=1.18.0
11+
onnx>=1.18.0,<1.20.0
1212
onnx_graphsurgeon>=0.5.2
1313
openai
1414
polygraphy
@@ -19,8 +19,6 @@ pandas
1919
h5py==3.12.1
2020
StrEnum
2121
sentencepiece>=0.1.99
22-
# WAR for tensorrt depending on the archived nvidia-cuda-runtime-cu13 package
23-
nvidia-cuda-runtime-cu13==0.0.0a0
2422
tensorrt~=10.13.0
2523
# https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel-25-10.html#rel-25-10 uses 2.9.0a0.
2624
torch>=2.9.0a0,<=2.9.0

tests/unittest/test_pip_install.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,51 @@ def download_wheel(args):
105105
shell=True)
106106

107107

108+
def install_tensorrt_llm():
109+
"""
110+
Installs the tensorrt_llm wheel, dynamically creating a torch constraint
111+
if torch is already installed to prevent it from being replaced.
112+
"""
113+
print("########## Install tensorrt_llm package ##########")
114+
115+
install_command = "pip3 install tensorrt_llm-*.whl"
116+
117+
# Always check for an existing torch installation, regardless of OS.
118+
try:
119+
print("Checking for existing torch installation...")
120+
torch_version_result = subprocess.run(
121+
['python3', '-c', 'import torch; print(torch.__version__)'],
122+
capture_output=True,
123+
text=True,
124+
check=True)
125+
torch_version = torch_version_result.stdout.strip()
126+
127+
if torch_version:
128+
print(f"Found installed torch version: {torch_version}")
129+
constraint_filename = "torch-constraint.txt"
130+
with open(constraint_filename, "w") as f:
131+
f.write(f"torch=={torch_version}\n")
132+
print(
133+
f"Created {constraint_filename} to constrain torch to version {torch_version}."
134+
)
135+
136+
# Modify install command to use the constraint
137+
install_command += f" -c {constraint_filename}"
138+
else:
139+
# This case is unlikely if the subprocess call succeeds
140+
print(
141+
"Could not determine installed torch version. Installing without constraint."
142+
)
143+
144+
except (subprocess.CalledProcessError, FileNotFoundError):
145+
# This handles cases where python3 fails or 'import torch' raises an error.
146+
print("Torch is not installed. Proceeding without constraint.")
147+
148+
# Execute the final installation command
149+
print(f"Executing command: {install_command}")
150+
subprocess.check_call(install_command, shell=True)
151+
152+
108153
def test_pip_install():
109154
parser = argparse.ArgumentParser(description="Check Pip Install")
110155
parser.add_argument("--wheel_path",
@@ -125,8 +170,8 @@ def test_pip_install():
125170
shell=True)
126171

127172
download_wheel(args)
128-
print("########## Install tensorrt_llm package ##########")
129-
subprocess.check_call("pip3 install tensorrt_llm-*.whl", shell=True)
173+
install_tensorrt_llm()
174+
130175
print("########## Test import tensorrt_llm ##########")
131176
subprocess.check_call(
132177
'python3 -c "import tensorrt_llm; print(tensorrt_llm.__version__)"',

0 commit comments

Comments
 (0)