Skip to content

Commit 7dc08c5

Browse files
authored
feat: Win/Linux Dual Compatible WORKSPACE + Upgrade CUDA + Upgrade PyT (#2907)
1 parent 0cb03a7 commit 7dc08c5

File tree

57 files changed

+431
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+431
-276
lines changed

.bazelrc

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
# | Build Configurations |
2222
# +------------------------------------------------------------+
2323
# Enable colorful output of GCC
24-
build --cxxopt="-fdiagnostics-color=always"
25-
build --cxxopt='-std=c++17'
26-
#build --linkopt="-Wl,--no-as-needed"
24+
build:default --cxxopt="-fdiagnostics-color=always"
25+
build:default --cxxopt='-std=c++17'
26+
#build:default --linkopt="-Wl,--no-as-needed"
2727

2828
build:windows --cxxopt="/GS-" --cxxopt="/std:c++17" --cxxopt="/permissive-"
2929
build:windows --cxxopt="/wd4244" --cxxopt="/wd4267" --cxxopt="/wd4819"

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.1
1+
6.3.2

.github/workflows/docgen.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ jobs:
1414
if: ${{ ! contains(github.actor, 'pytorchbot') }}
1515
environment: pytorchbot-env
1616
container:
17-
image: docker.io/pytorch/manylinux-builder:cuda12.1
17+
image: docker.io/pytorch/manylinux-builder:cuda12.4
1818
options: --gpus all
1919
env:
20-
CUDA_HOME: /usr/local/cuda-12.1
21-
VERSION_SUFFIX: cu121
20+
CUDA_HOME: /usr/local/cuda-12.4
21+
VERSION_SUFFIX: cu124
2222
CI_BUILD: 1
2323
steps:
2424
- uses: actions/checkout@v3
@@ -33,14 +33,14 @@ jobs:
3333
- name: Install base deps
3434
run: |
3535
python3 -m pip install pip --upgrade
36-
python3 -m pip install pyyaml numpy torch --pre --extra-index-url https://download.pytorch.org/whl/nightly/cu121
36+
python3 -m pip install pyyaml numpy torch --pre --extra-index-url https://download.pytorch.org/whl/nightly/cu124
3737
./packaging/pre_build_script.sh
3838
- name: Get HEAD SHA
3939
id: vars
4040
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
4141
- name: Build Python Package
4242
run: |
43-
python3 -m pip install --pre . --extra-index-url https://download.pytorch.org/whl/nightly/cu121
43+
python3 -m pip install --pre . --extra-index-url https://download.pytorch.org/whl/nightly/cu124
4444
- name: Generate New Docs
4545
run: |
4646
cd docsrc
@@ -61,4 +61,4 @@ jobs:
6161

6262
concurrency:
6363
group: ${{ github.workflow }}-${{ github.ref_name }}
64-
cancel-in-progress: true
64+
cancel-in-progress: true

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Torch-TensorRT
1515
---
1616
<div align="left">
1717

18-
Torch-TensorRT brings the power of TensorRT to PyTorch. Accelerate inference latency by up to 5x compared to eager execution in just one line of code.
18+
Torch-TensorRT brings the power of TensorRT to PyTorch. Accelerate inference latency by up to 5x compared to eager execution in just one line of code.
1919
</div></div>
2020

2121
## Installation
@@ -52,7 +52,7 @@ optimized_model(x) # this will be fast!
5252
```
5353

5454
### Option 2: Export
55-
If you want to optimize your model ahead-of-time and/or deploy in a C++ environment, Torch-TensorRT provides an export-style workflow that serializes an optimized module. This module can be deployed in PyTorch or with libtorch (i.e. without a Python dependency).
55+
If you want to optimize your model ahead-of-time and/or deploy in a C++ environment, Torch-TensorRT provides an export-style workflow that serializes an optimized module. This module can be deployed in PyTorch or with libtorch (i.e. without a Python dependency).
5656

5757
#### Step 1: Optimize + serialize
5858
```python
@@ -62,7 +62,7 @@ import torch_tensorrt
6262
model = MyModel().eval().cuda() # define your model here
6363
inputs = [torch.randn((1, 3, 224, 224)).cuda()] # define a list of representative inputs here
6464

65-
trt_gm = torch_tensorrt.compile(model, ir="dynamo", inputs)
65+
trt_gm = torch_tensorrt.compile(model, ir="dynamo", inputs)
6666
torch_tensorrt.save(trt_gm, "trt.ep", inputs=inputs) # PyTorch only supports Python runtime for an ExportedProgram. For C++ deployment, use a TorchScript file
6767
torch_tensorrt.save(trt_gm, "trt.ts", output_format="torchscript", inputs=inputs)
6868
```
@@ -116,9 +116,9 @@ auto results = trt_mod.forward({input_tensor});
116116
117117
These are the following dependencies used to verify the testcases. Torch-TensorRT can work with other versions, but the tests are not guaranteed to pass.
118118
119-
- Bazel 5.2.0
120-
- Libtorch 2.4.0.dev (latest nightly) (built with CUDA 12.4)
121-
- CUDA 12.1
119+
- Bazel 6.3.2
120+
- Libtorch 2.5.0.dev (latest nightly) (built with CUDA 12.4)
121+
- CUDA 12.4
122122
- TensorRT 10.0.1.6
123123
124124
## Deprecation Policy

WORKSPACE

+28-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ local_repository(
4343
new_local_repository(
4444
name = "cuda",
4545
build_file = "@//third_party/cuda:BUILD",
46-
path = "/usr/local/cuda-12.1/",
46+
path = "/usr/local/cuda-12.4/",
47+
)
48+
49+
new_local_repository(
50+
name = "cuda_win",
51+
build_file = "@//third_party/cuda:BUILD",
52+
path = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.4/",
4753
)
4854

4955
#############################################################################################################
@@ -54,14 +60,21 @@ http_archive(
5460
name = "libtorch",
5561
build_file = "@//third_party/libtorch:BUILD",
5662
strip_prefix = "libtorch",
57-
urls = ["https://download.pytorch.org/libtorch/nightly/cu121/libtorch-cxx11-abi-shared-with-deps-latest.zip"],
63+
urls = ["https://download.pytorch.org/libtorch/nightly/cu124/libtorch-cxx11-abi-shared-with-deps-latest.zip"],
5864
)
5965

6066
http_archive(
6167
name = "libtorch_pre_cxx11_abi",
6268
build_file = "@//third_party/libtorch:BUILD",
6369
strip_prefix = "libtorch",
64-
urls = ["https://download.pytorch.org/libtorch/nightly/cu121/libtorch-shared-with-deps-latest.zip"],
70+
urls = ["https://download.pytorch.org/libtorch/nightly/cu124/libtorch-shared-with-deps-latest.zip"],
71+
)
72+
73+
http_archive(
74+
name = "libtorch_win",
75+
build_file = "@//third_party/libtorch:BUILD",
76+
strip_prefix = "libtorch",
77+
urls = ["https://download.pytorch.org/libtorch/nightly/cu124/libtorch-win-shared-with-deps-latest.zip"],
6578
)
6679

6780
# Download these tarballs manually from the NVIDIA website
@@ -78,6 +91,18 @@ http_archive(
7891
],
7992
)
8093

94+
http_archive(
95+
name = "tensorrt_win",
96+
build_file = "@//third_party/tensorrt/archive:BUILD",
97+
sha256 = "d667bd10b178e239b621a8929008ef3e27967d181bf07a39845a0f99edeec47a",
98+
strip_prefix = "TensorRT-10.0.1.6",
99+
urls = [
100+
"https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.0.1/zip/TensorRT-10.0.1.6.Windows10.win10.cuda-12.4.zip",
101+
],
102+
)
103+
104+
105+
81106
####################################################################################
82107
# Locally installed dependencies (use in cases of custom dependencies or aarch64)
83108
####################################################################################

core/BUILD

+10-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ config_setting(
1717
},
1818
)
1919

20+
config_setting(
21+
name = "windows",
22+
constraint_values = [
23+
"@platforms//os:windows",
24+
],
25+
)
26+
2027
cc_library(
2128
name = "core",
2229
srcs = [
@@ -31,10 +38,10 @@ cc_library(
3138
"//core/partitioning",
3239
"//core/runtime",
3340
"//core/util/logging",
34-
"@tensorrt//:nvinfer",
3541
] + select({
36-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
37-
"//conditions:default": ["@libtorch"],
42+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
43+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
44+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
3845
}),
3946
alwayslink = True,
4047
)

core/conversion/BUILD

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "conversion",
1522
srcs = [
@@ -26,10 +33,10 @@ cc_library(
2633
"//core/conversion/var",
2734
"//core/ir",
2835
"//core/util:prelude",
29-
"@tensorrt//:nvinfer",
3036
] + select({
31-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
32-
"//conditions:default": ["@libtorch"],
37+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
38+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
39+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
3340
}),
3441
alwayslink = True,
3542
)

core/conversion/conversionctx/BUILD

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "conversionctx",
1522
srcs = [
@@ -21,10 +28,10 @@ cc_library(
2128
deps = [
2229
"//core/ir",
2330
"//core/util:prelude",
24-
"@tensorrt//:nvinfer",
2531
] + select({
26-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
27-
"//conditions:default": ["@libtorch"],
32+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
33+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
34+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
2835
}),
2936
alwayslink = True,
3037
)

core/conversion/converters/BUILD

+16-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "weights",
1522
srcs = [
@@ -21,10 +28,10 @@ cc_library(
2128
deps = [
2229
"//core/conversion/conversionctx",
2330
"//core/util:prelude",
24-
"@tensorrt//:nvinfer",
2531
] + select({
26-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
27-
"//conditions:default": ["@libtorch"],
32+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
33+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
34+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
2835
}),
2936
alwayslink = True,
3037
)
@@ -41,10 +48,10 @@ cc_library(
4148
":weights",
4249
"//core/conversion/conversionctx",
4350
"//core/util:prelude",
44-
"@tensorrt//:nvinfer",
4551
] + select({
46-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
47-
"//conditions:default": ["@libtorch"],
52+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
53+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
54+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
4855
}),
4956
alwayslink = True,
5057
)
@@ -98,10 +105,10 @@ cc_library(
98105
"//core/conversion/var",
99106
"//core/plugins:torch_tensorrt_plugins",
100107
"//core/util:prelude",
101-
"@tensorrt//:nvinfer",
102108
] + select({
103-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
104-
"//conditions:default": ["@libtorch"],
109+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
110+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
111+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
105112
}),
106113
alwayslink = True,
107114
)

core/conversion/evaluators/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "evaluators",
1522
srcs = [
@@ -28,6 +35,7 @@ cc_library(
2835
"//core/conversion/var",
2936
"//core/util:prelude",
3037
] + select({
38+
":windows": ["@libtorch_win//:libtorch"],
3139
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
3240
"//conditions:default": ["@libtorch"],
3341
}),

core/conversion/tensorcontainer/BUILD

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "tensorcontainer",
1522
srcs = [
@@ -20,10 +27,10 @@ cc_library(
2027
],
2128
deps = [
2229
"//core/util:prelude",
23-
"@tensorrt//:nvinfer",
2430
] + select({
25-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
26-
"//conditions:default": ["@libtorch"],
31+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
32+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
33+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
2734
}),
2835
alwayslink = True,
2936
)

core/conversion/var/BUILD

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "var",
1522
srcs = [
@@ -23,10 +30,10 @@ cc_library(
2330
"//core/conversion/converters:converter_util",
2431
"//core/conversion/tensorcontainer",
2532
"//core/util:prelude",
26-
"@tensorrt//:nvinfer",
2733
] + select({
28-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
29-
"//conditions:default": ["@libtorch"],
34+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
35+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
36+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
3037
}),
3138
alwayslink = True,
3239
)

core/ir/BUILD

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "ir",
1522
srcs = [
@@ -23,10 +30,10 @@ cc_library(
2330
],
2431
deps = [
2532
"//core/util:prelude",
26-
"@tensorrt//:nvinfer",
2733
] + select({
28-
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
29-
"//conditions:default": ["@libtorch"],
34+
":windows": ["@tensorrt_win//:nvinfer", "@libtorch_win//:libtorch"],
35+
":use_pre_cxx11_abi": ["@tensorrt//:nvinfer", "@libtorch_pre_cxx11_abi//:libtorch"],
36+
"//conditions:default": ["@tensorrt//:nvinfer", "@libtorch"],
3037
}),
3138
alwayslink = True,
3239
)

0 commit comments

Comments
 (0)