# How to solve "buildCudaEngine" cost long time

**URL:** <https://forums.developer.nvidia.com/t/how-to-solve-buildcudaengine-cost-long-time/61925>\
**Category:** Jetson TX2\
**Created:** [June 4, 2018, 6:15am UTC](https://forums.developer.nvidia.com/t/how-to-solve-buildcudaengine-cost-long-time/61925 "2018-06-04T06:15:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![380483397](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/380483397/32/11237_2.png) [@380483397](https://forums.developer.nvidia.com/u/380483397)\
**Post date:** [June 4, 2018, 6:15am UTC](https://forums.developer.nvidia.com/t/how-to-solve-buildcudaengine-cost-long-time/61925/1 "2018-06-04T06:15:11Z")

</div>

Hi,i use TensorRT API to create my net and when the program run to the line “engine\_ = builder\_-\>buildCudaEngine(\*network\_);”, it cost very long time, I want to know why and how to shorten the time ?

thanks!

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [June 4, 2018, 7:38am UTC](https://forums.developer.nvidia.com/t/how-to-solve-buildcudaengine-cost-long-time/61925/2 "2018-06-04T07:38:29Z")

</div>

Hi,

buildCudaEngine takes time since TensorRT optimizes the kernel with the information of model and GPU architecture.

A typical workflow is to serialize compiled engine(called PLAN) and relaunch TensorRT with PLAN to save building time.  
[url][Developer Guide :: NVIDIA Deep Learning TensorRT Documentation](https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html#wkflowdiagram%5B/url%5D)

Here is a sample code of PLAN serialize and de-serialize for your reference:  
[url][https://github.com/dusty-nv/jetson-inference/blob/master/tensorNet.cpp#L213[/url]](https://github.com/dusty-nv/jetson-inference/blob/master/tensorNet.cpp#L213%5B/url%5D)

Thanks.

---

<div class="post-metadata">

**Author:** ![380483397](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/380483397/32/11237_2.png) [@380483397](https://forums.developer.nvidia.com/u/380483397)\
**Post date:** [June 6, 2018, 1:03am UTC](https://forums.developer.nvidia.com/t/how-to-solve-buildcudaengine-cost-long-time/61925/3 "2018-06-06T01:03:16Z")

</div>

thanks for your reply.

I saved my PLAN to a file and then de-seialize from the PLAN file for my program, but next the line “nvinfer1::ICudaEngine\* engine = runtime-\>deserializeCudaEngine(modelMen, modelsize, &pluginFactory);” failed!

I guess the custom layer’s parameter is not saved in the PLAN file.can you give me some advise?

Is there any some demo for the PLAN file and contain custom layer ?

---

<div class="post-metadata">

**Author:** ![AastaLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/aastalll/32/14043_2.png) [@AastaLLL](https://forums.developer.nvidia.com/u/AastaLLL)\
**Post date:** [June 8, 2018, 7:20am UTC](https://forums.developer.nvidia.com/t/how-to-solve-buildcudaengine-cost-long-time/61925/4 "2018-06-08T07:20:15Z")

</div>

Hi,

You can find here for the plugin sample:

> **[GitHub - AastaNV/Face-Recognition: Demonstrate Plugin API for TensorRT2.1](https://github.com/AastaNV/Face-Recognition)**
>
> Demonstrate Plugin API for TensorRT2.1

Thanks.

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 18, 2021, 6:29pm UTC](https://forums.developer.nvidia.com/t/how-to-solve-buildcudaengine-cost-long-time/61925/5 "2021-10-18T18:29:18Z")

</div>

Closed on October 18, 2021, 6:29pm UTC


