The code that builds well in tensorRT 7.1.3 is tensorRT 8.0.1 gives the following error:

Hello,

The code that builds well in tensorRT 7.1.3 is
tensorRT 8.0.1 gives the following error:

How can we solve this problem?

/usr/include/aarch64-linux-gnu/NvInferRuntimeCommon.h:1222:18: error: overriding ‘virtual void nvinfer1::ILogger::log(nvinfer1::ILogger::Severity, const AsciiChar*) noexcept’
virtual void log(Severity severity, AsciiChar const* msg) noexcept = 0;

Thank you.

Hi,

The ILogger API has slightly changed in TensorRT 8.0.
Please update it with a similar way as below:

#include "logger.h"
...
sample::Logger logger;
nvinfer1::IRuntime* runtime = nvinfer1::createInferRuntime(logger);
...

Thanks.

1 Like

Hello,

Which file do I have to modify?

Thank you.

Hi,

Would you mind sharing the source of your app with us?
So we can check it for you?

Thanks.

1 Like

Hello,

It’s an open source.
URL: https://github.com/linghu8812/tensorrt_inference/tree/master/yolov5

I am getting the above error when building this project.
Can you please check what the problem is?
The method I found through the forum is at the URL below.

It seems to be a temporary solution, can you find a more fundamental solution?

Thank you.

Hi,

Please try to apply the following changes:

diff --git a/includes/common/common.hpp b/includes/common/common.hpp
index 398be37..dee73b9 100755
--- a/includes/common/common.hpp
+++ b/includes/common/common.hpp
@@ -5,6 +5,7 @@
 #include <numeric>
 #include <fstream>
 #include <dirent.h>
+#include "NvInferRuntimeCommon.h"
 #include "NvOnnxParser.h"
 #include "logging.h"

@@ -42,14 +43,14 @@ inline int64_t volume(const nvinfer1::Dims& d)
     return std::accumulate(d.d, d.d + d.nbDims, 1, std::multiplies<int64_t>());
 }

-Logger gLogger{Logger::Severity::kINFO};
-LogStreamConsumer gLogVerbose{LOG_VERBOSE(gLogger)};
-LogStreamConsumer gLogInfo{LOG_INFO(gLogger)};
-LogStreamConsumer gLogWarning{LOG_WARN(gLogger)};
-LogStreamConsumer gLogError{LOG_ERROR(gLogger)};
-LogStreamConsumer gLogFatal{LOG_FATAL(gLogger)};
+sample::Logger gLogger{sample::Logger::Severity::kINFO};
+sample::LogStreamConsumer gLogVerbose{sample::LOG_VERBOSE(gLogger)};
+sample::LogStreamConsumer gLogInfo{sample::LOG_INFO(gLogger)};
+sample::LogStreamConsumer gLogWarning{sample::LOG_WARN(gLogger)};
+sample::LogStreamConsumer gLogError{sample::LOG_ERROR(gLogger)};
+sample::LogStreamConsumer gLogFatal{sample::LOG_FATAL(gLogger)};

-void setReportableSeverity(Logger::Severity severity)
+void setReportableSeverity(sample::Logger::Severity severity)
 {
     gLogger.setReportableSeverity(severity);
     gLogVerbose.setReportableSeverity(severity);
diff --git a/includes/common/logging.h b/includes/common/logging.h
index 602b69f..a2934fe 100644
--- a/includes/common/logging.h
+++ b/includes/common/logging.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,9 @@
 #include <sstream>
 #include <string>

+namespace sample
+{
+
 using Severity = nvinfer1::ILogger::Severity;

 class LogStreamConsumerBuffer : public std::stringbuf
@@ -40,6 +43,8 @@ public:

     LogStreamConsumerBuffer(LogStreamConsumerBuffer&& other)
         : mOutput(other.mOutput)
+        , mPrefix(other.mPrefix)
+        , mShouldLog(other.mShouldLog)
     {
     }

@@ -81,11 +86,11 @@ public:
             // std::stringbuf::str() gets the string contents of the buffer
             // insert the buffer contents pre-appended by the appropriate prefix into the stream
             mOutput << mPrefix << str();
-            // set the buffer to empty
-            str("");
-            // flush the stream
-            mOutput.flush();
         }
+        // set the buffer to empty
+        str("");
+        // flush the stream
+        mOutput.flush();
     }

     void setShouldLog(bool shouldLog)
@@ -225,7 +230,7 @@ public:
     //! TODO Once all samples are updated to use this method to register the logger with TensorRT,
     //! we can eliminate the inheritance of Logger from ILogger
     //!
-    nvinfer1::ILogger& getTRTLogger()
+    nvinfer1::ILogger& getTRTLogger() noexcept
     {
         return *this;
     }
@@ -236,7 +241,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) noexcept override
     {
         LogStreamConsumer(mReportableSeverity, severity) << "[TRT] " << std::string(msg) << std::endl;
     }
@@ -305,8 +310,10 @@ public:
     //! \return a TestAtom that can be used in Logger::reportTest{Start,End}().
     static TestAtom defineTest(const std::string& name, int argc, char const* const* argv)
     {
+        // Append TensorRT version as info
+        const std::string vname = name + " [TensorRT v" + std::to_string(NV_TENSORRT_VERSION) + "]";
         auto cmdline = genCmdlineString(argc, argv);
-        return defineTest(name, cmdline);
+        return defineTest(vname, cmdline);
     }

     //!
@@ -425,7 +432,9 @@ private:
         for (int i = 0; i < argc; i++)
         {
             if (i > 0)
+            {
                 ss << " ";
+            }
             ss << argv[i];
         }
         return ss.str();
@@ -487,7 +496,7 @@ inline LogStreamConsumer LOG_ERROR(const Logger& logger)

 //!
 //! \brief produces a LogStreamConsumer object that can be used to log messages of severity kINTERNAL_ERROR
-//         ("fatal" severity)
+//!         ("fatal" severity)
 //!
 //! Example usage:
 //!
@@ -500,4 +509,6 @@ inline LogStreamConsumer LOG_FATAL(const Logger& logger)

 } // anonymous namespace

+} // namespace sample */
+
 #endif // TENSORRT_LOGGING_H

Thanks.

1 Like

Hello,

includes/common/common.h:31:8: error: ‘Logger’ does not name a type; did you mean ‘getLogger’?
 static Logger gLogger{Logger::Severity::kINFO};
        ^~~~~~
        getLogger
includes/common/common.h:32:8: error: ‘LogStreamConsumer’ does not name a type
 static LogStreamConsumer gLogVerbose{LOG_VERBOSE(gLogger)};
        ^~~~~~~~~~~~~~~~~
includes/common/common.h:33:8: error: ‘LogStreamConsumer’ does not name a type
 static LogStreamConsumer gLogInfo{LOG_INFO(gLogger)};
        ^~~~~~~~~~~~~~~~~
includes/common/common.h:34:8: error: ‘LogStreamConsumer’ does not name a type
 static LogStreamConsumer gLogWarning{LOG_WARN(gLogger)};
        ^~~~~~~~~~~~~~~~~
includes/common/common.h:35:8: error: ‘LogStreamConsumer’ does not name a type
 static LogStreamConsumer gLogError{LOG_ERROR(gLogger)};
        ^~~~~~~~~~~~~~~~~
includes/common/common.h:36:8: error: ‘LogStreamConsumer’ does not name a type
 static LogStreamConsumer gLogFatal{LOG_FATAL(gLogger)};
        ^~~~~~~~~~~~~~~~~
includes/common/common.h:57:28: error: variable or field ‘setReportableSeverity’ declared void
 void setReportableSeverity(Logger::Severity severity);
                            ^~~~~~
includes/common/common.h:57:28: error: ‘Logger’ has not been declared
includes/common/common.cpp:8:28: error: variable or field ‘setReportableSeverity’ declared void
 void setReportableSeverity(Logger::Severity severity)
                            ^~~~~~
includes/common/common.cpp:8:28: error: ‘Logger’ has not been declared

Can you tell me how to resolve these errors?

Thank you.

Dear @forumuser,
Have you applied the changes given in #7. Also, could you make changes to Logger class varaibles in common.h same as in common.hpp(like use sample::Logger instead of Logger, use sample::LogStreamConsumer instead of LogStreamConsumer etc) and confirm if it helps?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.