grimoire / amirstan_plugin

Useful tensorrt plugin. For pytorch and mmdetection model conversion.
MIT License
156 stars 38 forks source link

ERROR from primary_gie: Failed to create NvDsInferContext instance #19

Closed init-22 closed 3 years ago

init-22 commented 3 years ago

Hello there, I am getting an error while running the .engine file in Deepstream5.0,

(deepstream-app:1293189): GLib-GObject-WARNING **: 14:02:16.658: value "TRUE" of type 'gboolean' is invalid or out of range for property 'sync' of type 'gboolean'

(deepstream-app:1293189): GLib-GObject-WARNING : 14:02:16.658: value "TRUE" of type 'gboolean' is invalid or out of range for property 'qos' of type 'gboolean' ERROR: ../nvdsinfer/nvdsinfer_func_utils.cpp:62 Could not open lib: /mnt/2tb/general/amirstan_plugin/build/lib/libamirstan_plugin.so , error string: /mnt/2tb/general/amirstan_plugin/build/lib/libamirstan_plugin.so : cannot open shared object file: No such file or directory 0:00:01.364363794 1293189 0x55d2f18e6a60 ERROR nvinfer gstnvinfer.cpp:613:gst_nvinfer_logger: NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::initialize() [UID = 1]: Could not open custom lib: (null) 0:00:01.364412714 1293189 0x55d2f18e6a60 WARN nvinfer gstnvinfer.cpp:809:gst_nvinfer_start: error: Failed to create NvDsInferContext instance 0:00:01.364422612 1293189 0x55d2f18e6a60 WARN nvinfer gstnvinfer.cpp:809:gst_nvinfer_start: error: Config file path: /mnt/2tb/general/amirstan_plugin/build/lib/config_infer.txt, NvDsInfer Error: NVDSINFER_CUSTOM_LIB_FAILED ERROR: : Failed to set pipeline to PAUSED Quitting ERROR from primary_gie: Failed to create NvDsInferContext instance Debug info: gstnvinfer.cpp(809): gst_nvinfer_start (): /GstPipeline:pipeline/GstBin:primary_gie_bin/GstNvInfer:primary_gie: Config file path: /mnt/2tb/general/amirstan_plugin/build/lib/config_infer.txt, NvDsInfer Error: NVDSINFER_CUSTOM_LIB_FAILED App run failed

I made the following changes in the .txt file [property] net-scale-factor=0.0173 offsets=123.675;116.28;103.53 gpu-id=0 model-engine-file=models/my_model/model.engine labelfile-path=models/my_model/labels.txt batch-size=1 process-mode=1 model-color-format=0 network-mode=2 num-detected-classes=4 interval=0 gie-unique-id=1

output-blob-names=num_detections;boxes;scores;classes

force-implicit-batch-dim=1 parse-bbox-func-name=NvDsInferParseMmdet output-blob-names=num_detections;boxes;scores;classes custom-lib-path=libamirstan_plugin.so

grimoire commented 3 years ago

Hi, According to your log

ERROR: ../nvdsinfer/nvdsinfer_func_utils.cpp:62 Could not open lib: /mnt/2tb/general/amirstan_plugin/build/lib/libamirstan_plugin.so , error string: /mnt/2tb/general/amirstan_plugin/build/lib/libamirstan_plugin.so : cannot open shared object file: No such file or directory

It seems that deepstream did not find the plugin lib. Please set the right path of custom-lib-path and seem if it works.

init-22 commented 3 years ago

Hello, Yes, I’ve rechecked that and the path is correct.

On Mon, 5 Jul 2021 at 7:18 PM, q.yao @.***> wrote:

Hi, According to your log

ERROR: ../nvdsinfer/nvdsinfer_func_utils.cpp:62 Could not open lib: /mnt/2tb/general/amirstan_plugin/build/lib/libamirstan_plugin.so , error string: /mnt/2tb/general/amirstan_plugin/build/lib/libamirstan_plugin.so : cannot open shared object file: No such file or directory

It seems that deepstream did not find the plugin lib. Please set the right path of custom-lib-path and seem if it works.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/grimoire/amirstan_plugin/issues/19#issuecomment-874128223, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIGIWU2CT6BW2C6YU4Z2DL3TWGZ35ANCNFSM472IHYUA .

init-22 commented 3 years ago

Hey, after exporting the LD_LIBRARY_PATH, ldconfig and providing a full path solved this error. thanks a lot.

KleinYuan commented 9 months ago

@init-22 I met the same issue as you, but doing it inside a docker container. I install everything in /root/amirstan_plugin and did the following in Dockerfile

ENV LD_LIBRARY_PATH=/root/amirstan_plugin/build/lib:$LD_LIBRARY_PATH
RUN ldconfig -v

But I still have this issue

Starting pipeline 

0:00:00.500912449     8      0x4353590 WARN                 nvinfer gstnvinfer.cpp:643:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1170> [UID = 1]: Warning, OpenCV has been deprecated. Using NMS for clustering instead of cv::groupRectangles with topK = 20 and NMS Threshold = 0.5
ERROR: ../nvdsinfer/nvdsinfer_func_utils.cpp:30 Could not open lib: /root/amirstan_plugin/build/lib/libamirstan_plugin.so , error string: /root/amirstan_plugin/build/lib/libamirstan_plugin.so : cannot open shared object file: No such file or directory
0:00:00.501073053     8      0x4353590 ERROR                nvinfer gstnvinfer.cpp:640:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1257> [UID = 1]: Could not open custom lib: (null)
0:00:00.501083273     8      0x4353590 WARN                 nvinfer gstnvinfer.cpp:846:gst_nvinfer_start:<primary-inference> error: Failed to create NvDsInferContext instance
0:00:00.501089485     8      0x4353590 WARN                 nvinfer gstnvinfer.cpp:846:gst_nvinfer_start:<primary-inference> error: Config file path: /data/models/exp_model/pgie.config.txt, NvDsInfer Error: NVDSINFER_CUSTOM_LIB_FAILED
Error: gst-resource-error-quark: Failed to create NvDsInferContext instance (1): gstnvinfer.cpp(846): gst_nvinfer_start (): /GstPipeline:pipeline0/GstNvInfer:primary-inference:
Config file path: /model/pgie.txt, NvDsInfer Error: NVDSINFER_CUSTOM_LIB_FAILED
  1. I indeed built the amirstan_plugin with deepstream support flag
    • RUN cmake -DTENSORRT_DIR=/usr/src/tensorrt -DWITH_DEEPSTREAM=true -DDeepStream_DIR=/opt/nvidia/deepstream/deepstream ..
  2. /root/amirstan_plugin/build/lib/libamirstan_plugin.so does exist

Did you do anything else for this ?

@grimoire any hints ?

grimoire commented 9 months ago

@KleinYuan

error string: /root/amirstan_plugin/build/lib/libamirstan_plugin.so : cannot open shared object file: No such file or directory

Please check if you have build the library successfully.

KleinYuan commented 9 months ago

@grimoire based on the logs, the build is successful:

[  1%] Linking CXX static library ../../lib/libamir_cuda_util.a
[  5%] Built target amir_cuda_util
[  8%] Built target torchBmmPlugin_static
[ 11%] Linking CXX static library ../../../lib/libadaptivePoolPlugin_static.a
[ 11%] Linking CXX static library ../../../lib/libcarafeFeatureReassemblePlugin_static.a
[ 12%] Linking CXX static library ../../../lib/libdeformableConvPlugin_static.a
[ 14%] Linking CXX static library ../../../lib/libgridAnchorDynamicPlugin_static.a
[ 15%] Linking CXX static library ../../../lib/libdeformablePoolPlugin_static.a
[ 17%] Linking CXX static library ../../../lib/libroiExtractorPlugin_static.a
[ 18%] Linking CXX static library ../../../lib/libgroupNormPlugin_static.a
[ 20%] Linking CXX static library ../../../lib/libgridSamplePlugin_static.a
[ 21%] Linking CXX static library ../../../lib/libtorchUnfoldPlugin_static.a
[ 22%] Linking CXX static library ../../../lib/libtorchGatherPlugin_static.a
[ 24%] Linking CXX static library ../../../lib/libtorchEmbeddingPlugin_static.a
[ 25%] Linking CXX static library ../../../lib/libroiPoolPlugin_static.a
[ 28%] Built target adaptivePoolPlugin_static
[ 34%] Built target deformableConvPlugin_static
[ 37%] Built target carafeFeatureReassemblePlugin_static
[ 42%] Built target deformablePoolPlugin_static
[ 42%] Built target gridAnchorDynamicPlugin_static
[ 45%] Built target roiExtractorPlugin_static
[ 50%] Built target gridSamplePlugin_static
[ 51%] Built target torchUnfoldPlugin_static
[ 52%] Linking CXX static library ../../../lib/libtorchCumPlugin_static.a
[ 57%] Built target groupNormPlugin_static
[ 58%] Built target torchGatherPlugin_static
[ 61%] Built target torchEmbeddingPlugin_static
[ 64%] Built target roiPoolPlugin_static
[ 65%] Linking CXX static library ../../../lib/libtorchNMSPlugin_static.a
[ 67%] Linking CXX static library ../../../lib/libtorchCumMaxMinPlugin_static.a
[ 71%] Linking CXX static library ../../../lib/libdelta2bboxPlugin_static.a
[ 71%] Built target torchCumPlugin_static
[ 72%] Linking CXX static library ../../../lib/libbatchedNMSPlugin_static.a
[ 75%] Built target torchCumMaxMinPlugin_static
[ 78%] Built target torchNMSPlugin_static
[ 81%] Built target delta2bboxPlugin_static
[ 95%] Built target batchedNMSPlugin_static
[ 97%] Linking CXX shared library ../../lib/libamirstan_plugin.so
[100%] Built target amirstan_plugin
KleinYuan commented 9 months ago

ok, I eventually got it work and realize the issue is really that the order of the engine/func name/.so in the pgie of deepstream really matters :(