-
Notifications
You must be signed in to change notification settings - Fork 362
/
Copy pathgenerate-tensorrt-test-matrix.py
183 lines (164 loc) · 7.56 KB
/
generate-tensorrt-test-matrix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env python3
import argparse
import copy
import json
import sys
import requests # type: ignore[import-untyped]
# please update the cuda version you want to test with the future tensorRT version here
# channel: nightly if the future tensorRT version test workflow is triggered from the main branch or your personal branch
# channel: test if the future tensorRT version test workflow is triggered from the release branch(release/2.5 etc....)
CUDA_VERSIONS_DICT = {
"nightly": ["cu126"],
"test": ["cu124", "cu126"],
"release": ["cu124", "cu126"],
}
# please update the python version you want to test with the future tensorRT version here
# channel: nightly if the future tensorRT version test workflow is triggered from the main branch or your personal branch
# channel: test if the future tensorRT version test workflow is triggered from the release branch(release/2.5 etc....)
PYTHON_VERSIONS_DICT = {
"nightly": ["3.9"],
"test": ["3.9", "3.10", "3.11", "3.12"],
"release": ["3.9", "3.10", "3.11", "3.12"],
}
# please update the future tensorRT version you want to test here
TENSORRT_VERSIONS_DICT = {
"windows": {
"10.4.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.4.0/zip/TensorRT-10.4.0.26.Windows.win10.cuda-12.6.zip",
"strip_prefix": "TensorRT-10.4.0.26",
},
"10.5.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.5.0/zip/TensorRT-10.5.0.18.Windows.win10.cuda-12.6.zip",
"strip_prefix": "TensorRT-10.5.0.18",
},
"10.6.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.6.0/zip/TensorRT-10.6.0.26.Windows.win10.cuda-12.6.zip",
"strip_prefix": "TensorRT-10.6.0.26",
},
"10.7.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.7.0/zip/TensorRT-10.7.0.23.Windows.win10.cuda-12.6.zip",
"strip_prefix": "TensorRT-10.7.0.23",
},
},
"linux": {
"10.4.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.4.0/tars/TensorRT-10.4.0.26.Linux.x86_64-gnu.cuda-12.6.tar.gz",
"strip_prefix": "TensorRT-10.4.0.26",
},
"10.5.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.5.0/tars/TensorRT-10.5.0.18.Linux.x86_64-gnu.cuda-12.6.tar.gz",
"strip_prefix": "TensorRT-10.5.0.18",
},
"10.6.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.6.0/tars/TensorRT-10.6.0.26.Linux.x86_64-gnu.cuda-12.6.tar.gz",
"strip_prefix": "TensorRT-10.6.0.26",
},
"10.7.0": {
"urls": "https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.7.0/tars/TensorRT-10.7.0.23.Linux.x86_64-gnu.cuda-12.6.tar.gz",
"strip_prefix": "TensorRT-10.7.0.23",
},
},
}
def check_new_tensorrt_version(
major: int = 10, patch_from: int = 0
) -> tuple[bool, str, str, str, str]:
def check_file_availability(url: str) -> bool:
try:
response = requests.head(url, allow_redirects=True)
if response.status_code == 200:
content_type = response.headers.get("Content-Type", "")
content_disposition = response.headers.get("Content-Disposition", "")
if "application" in content_type or "attachment" in content_disposition:
return True
return False
except requests.RequestException:
return False
trt_linux_release_url = ""
trt_win_release_url = ""
# calculate the next minor version
minor = int(list(TENSORRT_VERSIONS_DICT["linux"].keys())[-1].split(".")[1]) + 1
trt_version = f"{major}.{minor}.0"
for patch in range(patch_from, 50):
for cuda_minor in range(4, 11):
trt_linux_release_url_candidate = f"https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/{trt_version}/tars/TensorRT-{trt_version}.{patch}.Linux.x86_64-gnu.cuda-12.{cuda_minor}.tar.gz"
if check_file_availability(trt_linux_release_url_candidate):
trt_linux_release_url = trt_linux_release_url_candidate
trt_win_release_url = f"https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/{trt_version}/zip/TensorRT-{trt_version}.{patch}.Windows.win10.cuda-12.{cuda_minor}.zip"
return (
True,
trt_version,
str(patch),
trt_linux_release_url,
trt_win_release_url,
)
return False, "", "", "", ""
def main(args: list[str]) -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
"--matrix",
help="matrix",
type=str,
default="",
)
options = parser.parse_args(args)
if options.matrix == "":
raise Exception("--matrix is empty, please provide the matrix json str")
matrix_dict = json.loads(options.matrix)
includes = matrix_dict["include"]
assert len(includes) > 0
if "channel" not in includes[0]:
raise Exception(f"channel field is missing from the matrix: {options.matrix}")
channel = includes[0]["channel"]
if channel not in ("nightly", "test", "release"):
raise Exception(
f"channel field: {channel} is not supported, currently supported value: nightly, test, release"
)
if "validation_runner" not in includes[0]:
raise Exception(
f"validation_runner field is missing from the matrix: {options.matrix}"
)
if "windows" in includes[0]["validation_runner"]:
arch = "windows"
elif "linux" in includes[0]["validation_runner"]:
arch = "linux"
else:
raise Exception(
f"{includes[0].validation_runner} is not the supported arch, currently only support windows and linux"
)
(
new_trt_available,
trt_version,
trt_patch,
trt_linux_release_url,
trt_win_release_url,
) = check_new_tensorrt_version(major=10, patch_from=0)
if new_trt_available:
TENSORRT_VERSIONS_DICT["linux"][trt_version] = {}
TENSORRT_VERSIONS_DICT["linux"][trt_version]["urls"] = trt_linux_release_url
TENSORRT_VERSIONS_DICT["linux"][trt_version][
"strip_prefix"
] = f"TensorRT-{trt_version}.{trt_patch}"
TENSORRT_VERSIONS_DICT["windows"][trt_version] = {}
TENSORRT_VERSIONS_DICT["windows"][trt_version]["urls"] = trt_win_release_url
TENSORRT_VERSIONS_DICT["windows"][trt_version][
"strip_prefix"
] = f"TensorRT-{trt_version}.{trt_patch}"
cuda_versions = CUDA_VERSIONS_DICT[channel]
python_versions = PYTHON_VERSIONS_DICT[channel]
tensorrt_versions = TENSORRT_VERSIONS_DICT[arch]
filtered_includes = []
for item in includes:
if (
item["desired_cuda"] in cuda_versions
and item["python_version"] in python_versions
):
for tensorrt_version, tensorrt_json in tensorrt_versions.items():
new_item = copy.deepcopy(item)
tensorrt_json["version"] = tensorrt_version
new_item["tensorrt"] = tensorrt_json
filtered_includes.append(new_item)
filtered_matrix_dict = {}
filtered_matrix_dict["include"] = filtered_includes
print(json.dumps(filtered_matrix_dict))
if __name__ == "__main__":
main(sys.argv[1:])