# Custom Model deployment on deepstream

**URL:** <https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523>\
**Category:** DeepStream SDK\
**Tags:** tensorrt, cuda\
**Created:** [June 4, 2022, 3:28pm UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523 "2022-06-04T15:28:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivam.mishra](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shivam.mishra](https://forums.developer.nvidia.com/u/shivam.mishra)\
**Post date:** [June 4, 2022, 3:28pm UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/1 "2022-06-04T15:28:05Z")

</div>

I have converted one tensorrt engine model from pytorch. It is basically a segementation model . Now when I am trying to run it on deepstream I am getting an error like this

Opening in BLOCKING MODE  
WARNING: [TRT]: Using an engine plan file across different models of devices is not recommended and is likely to affect performance or even cause errors.  
0:00:08.666316719 26834 0x17631b50 INFO nvinfer gstnvinfer.cpp:638:gst\_nvinfer\_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() \<nvdsinfer\_context\_impl.cpp:1900\> [UID = 1]: deserialized trt engine from :/opt/nvidia/deepstream/deepstream-6.0/sources/deepstream\_python\_apps/apps/deepstream-segmentation/trt\_fp32\_py.engine  
INFO: [Implicit Engine Info]: layers num: 2  
0 INPUT kFLOAT actual\_input 3x64x64  
1 OUTPUT kFLOAT output 6x64x64

0:00:08.668154258 26834 0x17631b50 INFO nvinfer gstnvinfer.cpp:638:gst\_nvinfer\_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() \<nvdsinfer\_context\_impl.cpp:2004\> [UID = 1]: Use deserialized engine model: /opt/nvidia/deepstream/deepstream-6.0/sources/deepstream\_python\_apps/apps/deepstream-segmentation/trt\_fp32\_py.engine  
0:00:08.712010507 26834 0x17631b50 INFO nvinfer gstnvinfer\_impl.cpp:313:notifyLoadModelStatus: [UID 1]: Load new model:model\_basic.txt sucessfully  
NvMMLiteBlockCreate : Block : BlockType = 256  
[JPEG Decode] BeginSequence Display WidthxHeight 3150x2100  
in videoconvert caps = video/x-raw(memory:NVMM), format=(string)RGBA, framerate=(fraction)1/1, width=(int)64, height=(int)64  
/dvs/git/dirty/git-master\_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:3885: =\> VIC Configuration failed image scale factor exceeds 16, use GPU for Transformation  
0:00:09.333505857 26834 0x7f240035e0 WARN nvinfer gstnvinfer.cpp:1376:convert\_batch\_and\_push\_to\_input\_thread: error: NvBufSurfTransform failed with error -2 while converting buffer  
Error: gst-stream-error-quark: NvBufSurfTransform failed with error -2 while converting buffer (1): /dvs/git/dirty/git-master\_linux/deepstream/sdk/src/gst-plugins/gst-nvinfer/gstnvinfer.cpp(1376): convert\_batch\_and\_push\_to\_input\_thread (): /GstPipeline:pipeline0/GstNvInfer:primary-nvinference-engine  
[JPEG Decode] NvMMLiteJPEGDecBlockPrivateClose done  
[JPEG Decode] NvMMLiteJPEGDecBlockClose done

My config files are:  
basic\_deepstream.txt

[application]  
enable-perf-measurement=1  
perf-measurement-interval-sec=5  
#gie-kitti-output-dir=streamscl

[tiled-display]  
enable=1  
rows=1  
columns=1  
width=1280  
height=720  
gpu-id=0  
#(0): nvbuf-mem-default - Default memory allocated, specific to particular platform  
#(1): nvbuf-mem-cuda-pinned - Allocate Pinned/Host cuda memory, applicable for Tesla  
#(2): nvbuf-mem-cuda-device - Allocate Device cuda memory, applicable for Tesla  
#(3): nvbuf-mem-cuda-unified - Allocate Unified cuda memory, applicable for Tesla  
#(4): nvbuf-mem-surface-array - Allocate Surface Array memory, applicable for Jetson  
nvbuf-memory-type=0

[source0]  
enable=1  
#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP  
type=3  
uri=file://./videoplayback.mp4  
num-sources=1  
#drop-frame-interval=2  
gpu-id=0

# (0): memtype\_device - Memory type Device

# (1): memtype\_pinned - Memory type Host Pinned

# (2): memtype\_unified - Memory type Unified

cudadec-memtype=0

[sink0]  
enable=1  
#Type - 1=FakeSink 2=EglSink 3=File  
type=5  
sync=0  
source-id=0  
gpu-id=0  
qos=0  
nvbuf-memory-type=0  
overlay-id=1

[sink1]  
enable=1  
type=3  
#1=mp4 2=mkv  
container=1  
#1=h264 2=h265  
codec=1

#encoder type 0=Hardware 1=Software  
enc-type=0  
sync=0  
#iframeinterval=10  
bitrate=2000000  
#H264 Profile - 0=Baseline 2=Main 4=High  
#H265 Profile - 0=Main 1=Main10  
profile=0  
output-file=out4.mp4  
source-id=0

[sink2]  
enable=0  
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming  
type=4  
#1=h264 2=h265  
codec=1  
#encoder type 0=Hardware 1=Software  
enc-type=0  
sync=0  
bitrate=4000000  
#H264 Profile - 0=Baseline 2=Main 4=High  
#H265 Profile - 0=Main 1=Main10  
profile=0

# set below properties in case of RTSPStreaming

rtsp-port=8554  
udp-port=5400

[osd]  
enable=1  
gpu-id=0  
border-width=1  
text-size=15  
text-color=1;1;1;1;  
font=Serif  
show-clock=0  
clock-x-offset=800  
clock-y-offset=820  
clock-text-size=12  
clock-color=1;0;0;0  
nvbuf-memory-type=0

[streammux]  
gpu-id=0  
##Boolean property to inform muxer that sources are live  
live-source=0  
batch-size=1  
##time out in usec, to wait after the first buffer is available  
##to push the batch even if the complete batch is not formed  
batched-push-timeout=40000

width=640  
height=480  
##enable to maintain aspect ratio wrt source, and allow black borders, works  
##along with width, height properties  
enable-padding=0  
nvbuf-memory-type=0

[primary-gie]

enable=1  
gpu-id=0  
batch-size=1  
interval=0  
model-engine-file=./trt\_fp32\_py.engine

nvbuf-memory-type=0  
config-file=model\_basic.txt

and model\_basic.txt is

[property]  
gpu-id=0  
net-scale-factor=1.0

model-color-format=0  
model-engine-file=./trt\_fp32\_py.engine

infer-dims=3;64;64  
#uff-input-order=0  
#uff-input-blob-name=data  
batch-size=1

## 0=FP32, 1=INT8, 2=FP16 mode

network-mode=0  
num-detected-classes=6  
interval=0  
gie-unique-id=1  
network-type=2  
#output-blob-names=last

segmentation-threshold=0.0

---

<div class="post-metadata">

**Author:** ![yingliu](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/yingliu/32/136703_2.png) [@yingliu](https://forums.developer.nvidia.com/u/yingliu)\
**Post date:** [June 6, 2022, 2:42am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/2 "2022-06-06T02:42:24Z")

</div>

Please provide complete information as applicable to your setup.  
**• Hardware Platform (Jetson / GPU)**  
**• DeepStream Version**  
**• 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)**  
**• The pipeline being used**

---

<div class="post-metadata">

**Author:** ![shivam.mishra](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shivam.mishra](https://forums.developer.nvidia.com/u/shivam.mishra)\
**Post date:** [June 6, 2022, 6:03am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/4 "2022-06-06T06:03:22Z")

</div>

- Hardware Platform Jetson Nano 4gb
- Deepstream Vesrion 6.0
- JetPack Version 4.6.2 (L4T 32.7.2]
- tensorrt==8.2.1.8
- I created a Project Folder inside /opt/nvidia/deepstream/deepstream-6.0/sources/Project/configs and inside it i created two custom file deepstream\_basic.txt and model\_basic.txt(content in these two is given above). I run the command in the folder /opt/nvidia/deepstream/deepstream-6.0/sources/Project$ deepstream-app -c deepstream\_basic.txt and i Got the error mentioned above.

I am not using any of the built-in deepstream models. I had my pytoorch model which I converted to ONNX then converted it .engine file. My model is for segmentation. Is there any way to deploy my custom trt engine model and have control over input ? Because in original model for prediction I have to preprocess the input , How can i do it in deepstream?

---

<div class="post-metadata">

**Author:** ![kesong](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kesong/32/101255_2.png) [@kesong](https://forums.developer.nvidia.com/u/kesong)\
**Post date:** [June 6, 2022, 11:38am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/5 "2022-06-06T11:38:59Z")

</div>

> [@shivam.mishra](#):
>
> /dvs/git/dirty/git-master\_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:3885: =\> VIC Configuration failed image scale factor exceeds 16, use GPU for Transformation

Seems there is video resize factor exceeds 16.

---

<div class="post-metadata">

**Author:** ![shivam.mishra](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shivam.mishra](https://forums.developer.nvidia.com/u/shivam.mishra)\
**Post date:** [June 6, 2022, 11:48am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/6 "2022-06-06T11:48:45Z")

</div>

How to resolve it?

---

<div class="post-metadata">

**Author:** ![kesong](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kesong/32/101255_2.png) [@kesong](https://forums.developer.nvidia.com/u/kesong)\
**Post date:** [June 7, 2022, 8:41am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/7 "2022-06-07T08:41:52Z")

</div>

Can you check your pipeline where need resize factor exceeds 16?

---

<div class="post-metadata">

**Author:** ![shivam.mishra](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shivam.mishra](https://forums.developer.nvidia.com/u/shivam.mishra)\
**Post date:** [June 14, 2022, 5:36am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/8 "2022-06-14T05:36:08Z")

</div>

sorry for the late reply, My error got solve by resizing the dimension of image inputs.

---

<div class="post-metadata">

**Author:** ![kesong](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kesong/32/101255_2.png) [@kesong](https://forums.developer.nvidia.com/u/kesong)\
**Post date:** [June 14, 2022, 9:25am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/9 "2022-06-14T09:25:12Z")

</div>

Glad to know the issue resolved.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [June 28, 2022, 9:25am UTC](https://forums.developer.nvidia.com/t/custom-model-deployment-on-deepstream/216523/10 "2022-06-28T09:25:22Z")

</div>

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