Skip to content

Commit

Permalink
Update installation of Torch-TRT
Browse files Browse the repository at this point in the history
  • Loading branch information
gs-olive committed Mar 22, 2024
1 parent 37a1725 commit e095e34
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pkg_tar(
pkg_tar(
name = "lib_rt",
srcs = select({
":windows": ["//cpp/lib:torch_tensorrt_runtime.dll"],
":windows": ["//cpp/lib:torchtrt_runtime.dll"],
"//conditions:default": [
"//cpp/lib:libtorchtrt_runtime.so",
],
Expand Down
11 changes: 11 additions & 0 deletions cpp/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ cc_binary(
"//cpp:torch_tensorrt",
],
)

cc_binary(
name = "torchtrt_runtime.dll",
srcs = [],
linkshared = True,
linkstatic = True,
deps = [
"//core/plugins:torch_tensorrt_plugins",
"//core/runtime",
],
)
30 changes: 30 additions & 0 deletions packaging/smoke_test_windows.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
import glob
import os
import shutil
import site
import subprocess

python_site_packages = site.getsitepackages()[-1]
extra_cudnn = os.path.join(python_site_packages, "nvidia", "cudnn")
extra_torch = os.path.join(python_site_packages, "torch", "lib")

print(f"CUDNN DLLS: {list(glob.glob(os.path.join(extra_cudnn, '**', '*.dll'), recursive=True))}")
print(f"ALL TORCH DLLS: {list(glob.glob(os.path.join(extra_torch, '**', '*.dll'), recursive=True))}")
print(f"Current PATH: {os.getenv('PATH')}")

# Move TRT cuDNN DLLs into torch path
for dll in glob.glob(os.path.join(extra_cudnn, "**", "*.dll"), recursive=True):
shutil.copy(dll, extra_torch)

import torch

print(f"Torch CUDA version: {torch.version.cuda}")

result = subprocess.run(
["nvcc", "--version"],
capture_output=True,
text=True,
)
print(result.stdout)
print(result.stderr)


import tensorrt
import torch_tensorrt
2 changes: 1 addition & 1 deletion py/torch_tensorrt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _register_with_torch() -> None:
"/torchtrt.dll" if sys.platform.startswith("win") else "/lib/libtorchtrt.so"
)
linked_file_runtime = (
"/torch_tensorrt_runtime.dll"
"/torchtrt_runtime.dll"
if sys.platform.startswith("win")
else "/lib/libtorchtrt_runtime.so"
)
Expand Down
8 changes: 4 additions & 4 deletions third_party/tensorrt/local/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ cc_library(
name = "nvinfer_headers",
hdrs = select({
":aarch64_linux": [
"include/aarch64-linux-gnu/NvUtils.h",
# "include/aarch64-linux-gnu/NvUtils.h",
] + glob(
[
"include/aarch64-linux-gnu/NvInfer*.h",
Expand All @@ -41,7 +41,7 @@ cc_library(
],
),
":ci_rhel_x86_64_linux": [
"include/NvUtils.h",
# "include/NvUtils.h",
] + glob(
[
"include/NvInfer*.h",
Expand All @@ -52,7 +52,7 @@ cc_library(
],
),
":windows": [
"include/NvUtils.h",
# "include/NvUtils.h",
] + glob(
[
"include/NvInfer*.h",
Expand All @@ -63,7 +63,7 @@ cc_library(
],
),
"//conditions:default": [
"include/x86_64-linux-gnu/NvUtils.h",
# "include/x86_64-linux-gnu/NvUtils.h",
] + glob(
[
"include/x86_64-linux-gnu/NvInfer*.h",
Expand Down

0 comments on commit e095e34

Please sign in to comment.