From 0c78095dd6b38a7c36620ddfecbe89e31a122b2e Mon Sep 17 00:00:00 2001 From: wang-xinyu Date: Sun, 9 Oct 2022 11:30:31 +0800 Subject: [PATCH] lenet5: support trt8 --- lenet/lenet.cpp | 2 +- lenet/logging.h | 3 ++- lenet/macros.h | 12 ++++++++++++ tutorials/getting_started.md | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 lenet/macros.h diff --git a/lenet/lenet.cpp b/lenet/lenet.cpp index 5fba240..b72777f 100644 --- a/lenet/lenet.cpp +++ b/lenet/lenet.cpp @@ -136,7 +136,7 @@ ICudaEngine* createLenetEngine(unsigned int maxBatchSize, IBuilder* builder, IBu // Build engine builder->setMaxBatchSize(maxBatchSize); - config->setMaxWorkspaceSize(1 << 20); + config->setMaxWorkspaceSize(16 << 20); ICudaEngine* engine = builder->buildEngineWithConfig(*network, *config); // Don't need the network any more diff --git a/lenet/logging.h b/lenet/logging.h index 602b69f..6b79a8b 100644 --- a/lenet/logging.h +++ b/lenet/logging.h @@ -25,6 +25,7 @@ #include #include #include +#include "macros.h" using Severity = nvinfer1::ILogger::Severity; @@ -236,7 +237,7 @@ public: //! Note samples should not be calling this function directly; it will eventually go away once we eliminate the //! inheritance from nvinfer1::ILogger //! - void log(Severity severity, const char* msg) override + void log(Severity severity, const char* msg) TRT_NOEXCEPT override { LogStreamConsumer(mReportableSeverity, severity) << "[TRT] " << std::string(msg) << std::endl; } diff --git a/lenet/macros.h b/lenet/macros.h new file mode 100644 index 0000000..0555103 --- /dev/null +++ b/lenet/macros.h @@ -0,0 +1,12 @@ +#ifndef __MACROS_H +#define __MACROS_H + +#if NV_TENSORRT_MAJOR >= 8 +#define TRT_NOEXCEPT noexcept +#define TRT_CONST_ENQUEUE const +#else +#define TRT_NOEXCEPT +#define TRT_CONST_ENQUEUE +#endif + +#endif // __MACROS_H diff --git a/tutorials/getting_started.md b/tutorials/getting_started.md index 19ce852..a9a4e8a 100644 --- a/tutorials/getting_started.md +++ b/tutorials/getting_started.md @@ -44,7 +44,7 @@ lenet out: tensor([[0.0950, 0.0998, 0.1101, 0.0975, 0.0966, 0.1097, 0.0948, 0.10 Clone the wang-xinyu/tensorrtx in your machine. Enter lenet folder, copy lenet5.wts generated above, and cmake&make c++ code. -And of course you should install cuda/cudnn/tensorrt first. +And of course you should install cuda/cudnn/tensorrt first. You might need to adapt the tensorrt path in CMakeLists.txt if you install tensorrt from tar package. ``` git clone https://github.com/wang-xinyu/tensorrtx