Hello,
We have trained our Pytorch Unet model and converted that into TRT using the torch2trt but while feeding that into the Deepstream- 6 we are facing the errors logged below
vm:~$ deepstream-segmentation-app -t infer /home/elio_admin/Downloads/deepstream_tao_apps/configs/unet_tao/pgie_unet_tao_config.txt *************.h264
Now playing: /***********3969791.h264,
ERROR: [TRT]: 1: [stdArchiveReader.cpp::StdArchiveReader::29] Error Code 1: Serialization (Serialization assertion magicTagRead == magicTag failed.Magic tag does not match)
ERROR: [TRT]: 4: [runtime.cpp::deserializeCudaEngine::76] Error Code 4: Internal Error (Engine deserialization failed.)
ERROR: ../nvdsinfer/nvdsinfer_model_builder.cpp:1528 Deserialize engine failed from file: /home/elio_admin/Downloads/deepstream_tao_apps/models/unet/CD_CD_ICG_100_swiched.trt
0:00:00.501323373 5912 0x5598ad991520 WARN nvinfer gstnvinfer.cpp:635:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1889> [UID = 1]: deserialize engine from file :/home/elio_admin/Downloads/deepstream_tao_apps/models/unet/CD_CD_ICG_100_swiched.trt failed
0:00:00.501387106 5912 0x5598ad991520 WARN nvinfer gstnvinfer.cpp:635:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:1996> [UID = 1]: deserialize backend context from engine from file :/home/elio_admin/Downloads/deepstream_tao_apps/models/unet/CD_CD_ICG_100_swiched.trt failed, try rebuild
0:00:00.501400602 5912 0x5598ad991520 INFO nvinfer gstnvinfer.cpp:638:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1914> [UID = 1]: Trying to create engine from model files
ERROR: ../nvdsinfer/nvdsinfer_model_builder.cpp:861 failed to build network since there is no model file matched.
ERROR: ../nvdsinfer/nvdsinfer_model_builder.cpp:799 failed to build network.
0:00:00.501915044 5912 0x5598ad991520 ERROR nvinfer gstnvinfer.cpp:632:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1934> [UID = 1]: build engine file failed
0:00:00.501935112 5912 0x5598ad991520 ERROR nvinfer gstnvinfer.cpp:632:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2020> [UID = 1]: build backend context failed
0:00:00.501945933 5912 0x5598ad991520 ERROR nvinfer gstnvinfer.cpp:632:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]: Error in NvDsInferContextImpl::initialize() <nvdsinfer_context_impl.cpp:1257> [UID = 1]: generate backend failed, check config file settings
0:00:00.501976872 5912 0x5598ad991520 WARN nvinfer gstnvinfer.cpp:841:gst_nvinfer_start:<primary-nvinference-engine> error: Failed to create NvDsInferContext instance
0:00:00.501984748 5912 0x5598ad991520 WARN nvinfer gstnvinfer.cpp:841:gst_nvinfer_start:<primary-nvinference-engine> error: Config file path: /home/elio_admin/Downloads/deepstream_tao_apps/configs/unet_tao/pgie_unet_tao_config.txt, NvDsInfer Error: NVDSINFER_CONFIG_FAILED
Running...
ERROR from element primary-nvinference-engine: Failed to create NvDsInferContext instance
Error details: gstnvinfer.cpp(841): gst_nvinfer_start (): /GstPipeline:dstest-image-decode-pipeline/GstNvInfer:primary-nvinference-engine:
Config file path: /home/elio_admin/Downloads/deepstream_tao_apps/configs/unet_tao/pgie_unet_tao_config.txt, NvDsInfer Error: NVDSINFER_CONFIG_FAILED
Returned, stopping playback
Deleting pipeline
We have converted our model into trt on same machine as deepstream execution server, having same TensorRT version using the snippet below
import torch2trt
x = torch.ones((1, 3, 320, 480)).cuda().half()
model = SegModel(n_classes=3)
checkpoint = args.model_file
a = torch.load(checkpoint)
model.load_state_dict(a['state_dict'], strict=False)
model1 = model.cuda().eval().half()
model_w = model1.half()
#args.tensorrt_file: 'alexnet_trt.pth'
model_trt = torch2trt.torch2trt(model_w, [torch.tensor(x, dtype=torch.half, device='cuda:0')], fp16_mode=True)
torch.save(model_trt.state_dict(), args.tensorrt_file)
Any help and suggestion would be appreciated
Thanks in Advance !!!
** Hardware Platform : NVIDIA RTX A6000
** DeepStream Version:
deepstream-app version 6.0.1, DeepStreamSDK 6.0.1, CUDA Driver Version: 11.6, CUDA Runtime Version: 11.4, TensorRT Version: 8.4, cuDNN Version: 8.4, libNVWarp360 Version: 2.0.1d3
** NVIDIA GPU Driver Version : Driver Version: 510.60.02