Skip to content

Commit 1fe36cd

Browse files
borisfomperi044
authored andcommitted
TRT 8.0 fixes for trtorchc
Signed-off-by: Boris Fomitchev <[email protected]>
1 parent 27f7acb commit 1fe36cd

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

WORKSPACE

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ git_repository(
3434
# CUDA should be installed on the system locally
3535
new_local_repository(
3636
name = "cuda",
37-
path = "/usr/local/cuda",
3837
build_file = "@//third_party/cuda:BUILD",
38+
path = "/usr/local/cuda-11.1/",
3939
)
4040

4141
new_local_repository(
@@ -67,23 +67,25 @@ http_archive(
6767
# Either place them in the distdir directory in third_party and use the --distdir flag
6868
# or modify the urls to "file:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz
6969

70-
#http_archive(
71-
# name = "cudnn",
72-
# urls = ["file:///home/boris/git/TRTorch/third_party/dist_dir/x86_64-linux-gnu/cudnn-11.2-linux-x64-v8.1.1.33.tgz",],
73-
# # "https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.1.33/11.2_20210301/cudnn-11.2-linux-x64-v8.1.1.33.tgz",],
74-
# build_file = "@//third_party/cudnn/archive:BUILD",
75-
# sha256 = "98a8784e92862f20018d20c281b30d4a0cd951f93694f6433ccf4ae9c502ba6a",
76-
# strip_prefix = "cuda"
77-
#)
70+
http_archive(
71+
name = "cudnn",
72+
build_file = "@//third_party/cudnn/archive:BUILD",
73+
sha256 = "98a8784e92862f20018d20c281b30d4a0cd951f93694f6433ccf4ae9c502ba6a",
74+
strip_prefix = "cuda",
75+
urls = [
76+
"https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.1.33/11.2_20210301/cudnn-11.2-linux-x64-v8.1.1.33.tgz",
77+
],
78+
)
7879

79-
#http_archive(
80-
# name = "tensorrt",
81-
# urls = ["file:///home/boris/git/TRTorch/third_party/dist_dir/x86_64-linux-gnu/TensorRT-7.2.3.4.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.1.tar.gz"],
82-
# "https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.2.3/tars/TensorRT-7.2.3.4.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.1.tar.gz",],
83-
# build_file = "@//third_party/tensorrt/archive:BUILD",
84-
# strip_prefix = "TensorRT-7.2.3.4",
85-
# sha256 = "d3a1f478e304b48878604fac70ce7920fece71f9cac62f925c9c59c197f5d087"
86-
#)
80+
http_archive(
81+
name = "tensorrt",
82+
build_file = "@//third_party/tensorrt/archive:BUILD",
83+
sha256 = "d3a1f478e304b48878604fac70ce7920fece71f9cac62f925c9c59c197f5d087",
84+
strip_prefix = "TensorRT-7.2.3.4",
85+
urls = [
86+
"https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.2.3/tars/TensorRT-7.2.3.4.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.1.tar.gz",
87+
],
88+
)
8789

8890
####################################################################################
8991
# Locally installed dependencies (use in cases of custom dependencies or aarch64)
@@ -108,17 +110,17 @@ http_archive(
108110
# build_file = "third_party/libtorch/BUILD"
109111
#)
110112

111-
new_local_repository(
112-
name = "cudnn",
113-
path = "/usr/",
114-
build_file = "@//third_party/cudnn/local:BUILD"
115-
)
113+
#new_local_repository(
114+
# name = "cudnn",
115+
# path = "/usr/",
116+
# build_file = "@//third_party/cudnn/local:BUILD"
117+
#)
116118

117-
new_local_repository(
118-
name = "tensorrt",
119-
path = "/usr/",
120-
build_file = "@//third_party/tensorrt/local:BUILD"
121-
)
119+
#new_local_repository(
120+
# name = "tensorrt",
121+
# path = "/usr/",
122+
# build_file = "@//third_party/tensorrt/local:BUILD"
123+
#)
122124

123125
#########################################################################
124126
# Testing Dependencies (optional - comment out on aarch64)

cpp/api/include/trtorch/ptq.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Int8Calibrator : Algorithm {
7777
*
7878
* @return int
7979
*/
80-
int getBatchSize() const override {
80+
int getBatchSize() const noexcept override {
8181
// HACK: TRTorch only uses explict batch sizing, INT8 Calibrator does not
8282
// work when reporting the batch size here and having explicity batching.
8383
// So we just report batch size 1 (warnings will still be printed out).
@@ -96,7 +96,7 @@ class Int8Calibrator : Algorithm {
9696
* @return true - There is a new batch for the calibrator to consume
9797
* @return false - There is not a new batch for the calibrator to consume
9898
*/
99-
bool getBatch(void* bindings[], const char* names[], int nbBindings) override {
99+
bool getBatch(void* bindings[], const char* names[], int nbBindings) noexcept override {
100100
if (it_ != batched_data_.end()) {
101101
auto status = get_batch_impl(bindings, names, nbBindings, *it_);
102102
it_ = ++it_;
@@ -116,7 +116,7 @@ class Int8Calibrator : Algorithm {
116116
* @param length
117117
* @return const void* - Pointer to cache data
118118
*/
119-
const void* readCalibrationCache(size_t& length) override {
119+
const void* readCalibrationCache(size_t& length) noexcept override {
120120
if (use_cache_) {
121121
std::stringstream ss;
122122
ss << "Reading Calibration Cache from " << cache_file_path_;
@@ -143,7 +143,7 @@ class Int8Calibrator : Algorithm {
143143
* @param cache: const void* - cache data
144144
* @param length: size_t - length of cache
145145
*/
146-
void writeCalibrationCache(const void* cache, size_t length) override {
146+
void writeCalibrationCache(const void* cache, size_t length) noexcept override {
147147
std::ofstream cache_file(cache_file_path_, std::ios::binary);
148148
cache_file.write(reinterpret_cast<const char*>(cache), length);
149149
std::stringstream ss;
@@ -203,7 +203,7 @@ class Int8CacheCalibrator : Algorithm {
203203
*
204204
* @return int
205205
*/
206-
int getBatchSize() const override {
206+
int getBatchSize() const noexcept override {
207207
// HACK: TRTorch only uses explict batch sizing, INT8 Calibrator does not
208208
// work when reporting the batch size here and having explicity batching.
209209
// So we just report batch size 1 (warnings will still be printed out).
@@ -222,7 +222,7 @@ class Int8CacheCalibrator : Algorithm {
222222
* @param nbBindings: int - Number of bindings
223223
* @return false
224224
*/
225-
bool getBatch(void* bindings[], const char* names[], int nbBindings) override {
225+
bool getBatch(void* bindings[], const char* names[], int nbBindings) noexcept override {
226226
return false;
227227
}
228228

@@ -234,7 +234,7 @@ class Int8CacheCalibrator : Algorithm {
234234
* @param length
235235
* @return const void* - Pointer to cache data
236236
*/
237-
const void* readCalibrationCache(size_t& length) override {
237+
const void* readCalibrationCache(size_t& length) noexcept override {
238238
std::stringstream ss;
239239
ss << "Reading Calibration Cache from " << cache_file_path_;
240240
logging::log(logging::Level::kINFO, ss.str());
@@ -258,7 +258,7 @@ class Int8CacheCalibrator : Algorithm {
258258
* @param cache: const void* - cache data
259259
* @param length: size_t - length of cache
260260
*/
261-
void writeCalibrationCache(const void* cache, size_t length) override {
261+
void writeCalibrationCache(const void* cache, size_t length) noexcept override {
262262
std::ofstream cache_file(cache_file_path_, std::ios::binary);
263263
cache_file.write(reinterpret_cast<const char*>(cache), length);
264264
std::stringstream ss;

0 commit comments

Comments
 (0)