Can not save engine file

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) jetson AGX Xavier
• DeepStream Version 6.1
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

I am new to Deepstream. when i run the deepstream-test1 app I don’t find any saved engine file in the path specified for engine file. It is taking 1-2 mins to start the app every time i run the app. How do i save the engine file so that I can run the app quickly? I am running the app with following command.

python3 deepstream_test_1.py <h264_elementary_stream>

There is no engine file when the program runs for the first time, thus need create the engine file. After that it will be faster as the engine file can be reused.

But It is taking the same time when i run it again, It is not faster. I don’t find any engine file created in the following path

model-engine-file=…/…/…/…/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine

please check the terminal logs, there will be the path of new engine, then replace model-engine-file’s value with the path in log. for example:
serialize cuda engine to file: /opt/nvidia/deepstream/deepstream/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine successfully

I have the following messages in terminal

Creating Pipeline

Creating Source

Creating H264Parser

Creating Decoder

Creating EGLSink

Playing file /home/nvidia/Downloads/vid.264
Adding elements to Pipeline

Linking elements in the Pipeline

Starting pipeline

Using winsys: x11
Opening in BLOCKING MODE
0:00:00.573545673 221481 0x414cd890 WARN nvinfer gstnvinfer.cpp:643:gst_nvinfer_logger: 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
WARNING: Deserialize engine failed because file path: /opt/nvidia/deepstream/deepstream-6.1/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine open error
0:00:04.450211902 221481 0x414cd890 WARN nvinfer gstnvinfer.cpp:643:gst_nvinfer_logger: NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1897> [UID = 1]: deserialize engine from file :/opt/nvidia/deepstream/deepstream-6.1/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine failed
0:00:04.514037703 221481 0x414cd890 WARN nvinfer gstnvinfer.cpp:643:gst_nvinfer_logger: NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2002> [UID = 1]: deserialize backend context from engine from file :/opt/nvidia/deepstream/deepstream-6.1/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine failed, try rebuild
0:00:04.514399991 221481 0x414cd890 INFO nvinfer gstnvinfer.cpp:646:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1923> [UID = 1]: Trying to create engine from model files
WARNING: [TRT]: The implicit batch dimension mode has been deprecated. Please create the network with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag whenever possible.
WARNING: Serialize engine failed because of file path: /opt/nvidia/deepstream/deepstream-6.1/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine opened error
0:01:08.929752188 221481 0x414cd890 WARN nvinfer gstnvinfer.cpp:643:gst_nvinfer_logger: NvDsInferContext[UID 1]: Warning from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1950> [UID = 1]: failed to serialize cude engine to file: /opt/nvidia/deepstream/deepstream-6.1/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
INFO: [Implicit Engine Info]: layers num: 3
0 INPUT kFLOAT input_1 3x368x640
1 OUTPUT kFLOAT conv2d_bbox 16x23x40
2 OUTPUT kFLOAT conv2d_cov/Sigmoid 4x23x40

0:01:09.014779931 221481 0x414cd890 INFO nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus: [UID 1]: Load new model:dstest1_pgie_config.txt sucessfully
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Frame Number=0 Number of Objects=5 Vehicle_count=5 Person_count=0
Frame Number=1 Number of Objects=5 Vehicle_count=5 Person_count=0
Frame Number=2 Number of Objects=4 Vehicle_count=4 Person_count=0
Frame Number=3 Number of Objects=6 Vehicle_count=6 Person_count=0
Frame Number=4 Number of Objects=3 Vehicle_count=3 Person_count=0
Frame Number=5 Number of Objects=4 Vehicle_count=4 Person_count=0
Frame Number=6 Number of Objects=5 Vehicle_count=5 Person_count=0
Frame Number=7 Number of Objects=5 Vehicle_count=5 Person_count=0
Frame Number=8 Number of Objects=3 Vehicle_count=3 Person_count=0

Here it says failed to serialize cude engine to file: /opt/nvidia/deepstream/deepstream-6.1/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine.

std::ofstream fileOut(path, std::ios::binary);
if (!fileOut.is_open())

nvinfer plugin + nviner lowlovel lib are opensource. as the code in opt\nvidia\deepstream\deepstream\sources\libs\nvdsinfer\nvdsinfer_model_builder.cpp shown, std::ofstream open() failed, please check the following:

  1. check if have permission to write in /opt/nvidia/deepstream/deepstream-6.1/samples/models/Primary_Detector/
  2. check if disk is full.
  3. add code printf(“errno = %d\n”, errno); to get the failure reason.

Thank you. It worked after i gave it the write permissions.

Glad to know you fixed it, thanks for the update! If need further support, please open a new one. Thanks

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