I have checked my trt inference code, it can work as expected with other 'fp16models. And also i tested with several random inputs, it will still outputNaN` values. Any solutions?
And the inference in our project can work properly with other fp16 models, except this one, so would you mind helping me to check if it is a specific layer inside the model that will generate NaN value after changing it to trt model? Or will it work on other versions of jp/trt ?
The testing is just trying to locate the root cause.
Based on the log above, it seems that only part of the output becomes NAN.
So just want to check if setting batchsize=1 can generate the correct result.
We try to reproduce this issue in our environment as well.
But the source shared in Set 21 includes another file called testnet.h.
Could you share the file with us as well?
Thanks for sharing the header.
But still some function missing:
$ nvcc nvidia_test.cpp -o test -I/usr/include/opencv4/ -I/usr/src/tensorrt/samples/common/ -I./
nvidia_test.cpp: In function ‘bool readTrtFile(const string&, nvinfer1::ICudaEngine*&)’:
nvidia_test.cpp:106:99: warning: ‘nvinfer1::ICudaEngine* nvinfer1::IRuntime::deserializeCudaEngine(const void*, std::size_t, nvinfer1::IPluginFactory*)’ is deprecated [-Wdeprecated-declarations]
106 | engine = trtRuntime->deserializeCudaEngine(cached_engine.data(), cached_engine.size(), nullptr);
| ^
In file included from /usr/include/aarch64-linux-gnu/NvInfer.h:17,
from testnet.h:6,
from nvidia_test.cpp:1:
/usr/include/aarch64-linux-gnu/NvInferRuntime.h:637:43: note: declared here
637 | TRT_DEPRECATED nvinfer1::ICudaEngine* deserializeCudaEngine(
| ^~~~~~~~~~~~~~~~~~~~~
nvidia_test.cpp: In constructor ‘testnet::testnet(const string&)’:
nvidia_test.cpp:121:21: error: ‘readCOCOLabel’ was not declared in this scope
121 | detect_labels = readCOCOLabel(labels_file);
| ^~~~~~~~~~~~~
nvidia_test.cpp: At global scope:
nvidia_test.cpp:141:6: error: no declaration matches ‘void testnet::InferenceFolder(const string&)’
141 | void testnet::InferenceFolder(const std::string &folder_name) {
| ^~~~~~~
In file included from nvidia_test.cpp:1:
testnet.h:23:10: note: candidate is: ‘bool testnet::InferenceFolder(const string&)’
23 | bool InferenceFolder(const std::string &folder_name);
| ^~~~~~~~~~~~~~~
testnet.h:8:7: note: ‘class testnet’ defined here
8 | class testnet{
| ^~~~~~~
nvidia_test.cpp: In member function ‘void testnet::EngineInference(const std::vector<std::__cxx11::basic_string<char> >&, const int&, void**, const std::vector<long int>&, cudaStream_t)’:
nvidia_test.cpp:267:40: error: ‘save_dir’ was not declared in this scope
267 | std::string rst_name = save_dir + tmp;
| ^~~~~~~~
nvidia_test.cpp: At global scope:
nvidia_test.cpp:279:9: error: no declaration matches ‘cv::Mat testnet::preprocess(cv::Mat)’
279 | cv::Mat testnet::preprocess(cv::Mat img) {
| ^~~~~~~
nvidia_test.cpp:279:9: note: no functions named ‘cv::Mat testnet::preprocess(cv::Mat)’
In file included from nvidia_test.cpp:1:
testnet.h:8:7: note: ‘class testnet’ defined here
8 | class testnet{
| ^~~~~~~
nvidia_test.cpp: In member function ‘std::vector<float> testnet::prepareImage(std::vector<cv::Mat>&)’:
nvidia_test.cpp:284:1: warning: no return statement in function returning non-void [-Wreturn-type]
284 | }
| ^
nvidia_test.cpp: In member function ‘std::vector<std::vector<testnet::DetectRes> > testnet::postProcess(const std::vector<cv::Mat>&, float*, const int&)’:
nvidia_test.cpp:289:1: warning: no return statement in function returning non-void [-Wreturn-type]
289 | }
| ^