Skip to content

Commit 823bb0a

Browse files
committed
Fix dll locations
1 parent 4f2c092 commit 823bb0a

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

py/torch_tensorrt/__init__.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,28 @@ def _find_lib(name: str, paths: List[str]) -> str:
9090

9191
def _register_with_torch() -> None:
9292
trtorch_dir = os.path.dirname(__file__)
93-
linked_file = (
94-
"/torchtrt.dll" if sys.platform.startswith("win") else "/lib/libtorchtrt.so"
93+
linked_file = os.path.join(
94+
"lib", ("torchtrt.dll" if sys.platform.startswith("win") else "libtorchtrt.so")
9595
)
96-
linked_file_runtime = (
97-
"/torchtrt_runtime.dll"
98-
if sys.platform.startswith("win")
99-
else "/lib/libtorchtrt_runtime.so"
96+
linked_file_runtime = os.path.join(
97+
"lib",
98+
(
99+
"torchtrt_runtime.dll"
100+
if sys.platform.startswith("win")
101+
else "libtorchtrt_runtime.so"
102+
),
100103
)
101-
if os.path.isfile(trtorch_dir + linked_file):
104+
linked_file_full_path = os.path.join(trtorch_dir, linked_file)
105+
linked_file_runtime_full_path = os.path.join(trtorch_dir, linked_file_runtime)
106+
107+
if os.path.isfile(linked_file_full_path):
102108
assert ENABLED_FEATURES.torchscript_frontend
103109
assert ENABLED_FEATURES.torch_tensorrt_runtime
104-
torch.ops.load_library(trtorch_dir + linked_file)
105-
elif os.path.isfile(trtorch_dir + linked_file_runtime):
110+
torch.ops.load_library(linked_file_full_path)
111+
112+
elif os.path.isfile(linked_file_runtime_full_path):
106113
assert ENABLED_FEATURES.torch_tensorrt_runtime
107-
torch.ops.load_library(trtorch_dir + linked_file_runtime)
114+
torch.ops.load_library(linked_file_runtime_full_path)
108115

109116

110117
_register_with_torch()

0 commit comments

Comments
 (0)