Skip to content

Commit ae902d4

Browse files
committed
Use dllist on linux to check cross compile feature
1 parent 9b73a8e commit ae902d4

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

py/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ pybind11==2.6.2
55
torch>=2.8.0.dev,<2.9.0
66
torchvision>=0.22.0.dev,<0.23.0
77
--extra-index-url https://pypi.ngc.nvidia.com
8-
pyyaml
8+
pyyaml
9+
dllist

py/torch_tensorrt/_utils.py

+7-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from typing import Any
55

66
import torch
7-
from torch_tensorrt import _find_lib
87

98

109
def sanitized_torch_version() -> Any:
@@ -16,24 +15,13 @@ def sanitized_torch_version() -> Any:
1615

1716

1817
def check_cross_compile_trt_win_lib():
19-
if sys.platform.startswith("linux"):
20-
LINUX_PATHS = ["/usr/local/cuda-12.8/lib64", "/usr/lib", "/usr/lib64"]
21-
22-
if platform.uname().processor == "x86_64":
23-
LINUX_PATHS += [
24-
"/usr/lib/x86_64-linux-gnu",
25-
]
26-
elif platform.uname().processor == "aarch64":
27-
LINUX_PATHS += ["/usr/lib/aarch64-linux-gnu"]
18+
# cross compile feature is only available on linux
19+
# build engine on linux and run on windows
20+
import dllist
2821

29-
LINUX_LIBS = [
30-
f"libnvinfer_builder_resource_win.so.*",
31-
]
32-
33-
for lib in LINUX_LIBS:
34-
try:
35-
ctypes.CDLL(_find_lib(lib, LINUX_PATHS))
22+
if sys.platform.startswith("linux"):
23+
loaded_libs = dllist.dllist()
24+
target_lib = "libnvinfer_builder_resource_win.so.*"
25+
if target_lib in loaded_libs:
3626
return True
37-
except:
38-
continue
3927
return False

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ requires = [
1313
"pybind11==2.6.2",
1414
"numpy",
1515
"sympy",
16+
"dllist",
1617
]
1718
build-backend = "setuptools.build_meta"
1819

@@ -63,6 +64,7 @@ dependencies = [
6364
"packaging>=23",
6465
"numpy",
6566
"typing-extensions>=4.7.0",
67+
"dllist",
6668
]
6769

6870
dynamic = ["version"]

0 commit comments

Comments
 (0)