# How to release all gpu memory after saving built engine?

**URL:** <https://forums.developer.nvidia.com/t/how-to-release-all-gpu-memory-after-saving-built-engine/221038>\
**Category:** TensorRT\
**Tags:** tensorrt\
**Created:** [July 18, 2022, 2:36am UTC](https://forums.developer.nvidia.com/t/how-to-release-all-gpu-memory-after-saving-built-engine/221038 "2022-07-18T02:36:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaoyan\_shi93](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@shaoyan\_shi93](https://forums.developer.nvidia.com/u/shaoyan_shi93)\
**Post date:** [July 18, 2022, 2:36am UTC](https://forums.developer.nvidia.com/t/how-to-release-all-gpu-memory-after-saving-built-engine/221038/1 "2022-07-18T02:36:08Z")

</div>

## Description

how to release all gpu memory after saving built engine ? I have destoried builder ,parser,giemodel and engine ,but there are about 1GB gpu memory has not released? how can I releaseit?

## Environment

**TensorRT Version** : 8.2.4.15  
**GPU Type** : gtx1660  
**Nvidia Driver Version** : 511.23  
**CUDA Version** : 11.6  
**CUDNN Version** : 8  
**Operating System + Version** : windows10  
**Python Version (if applicable)**: 3.8  
**PyTorch Version (if applicable)**: 1.9.1

---

<div class="post-metadata">

**Author:** ![spolisetty](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/spolisetty/32/14047_2.png) [@spolisetty](https://forums.developer.nvidia.com/u/spolisetty)\
**Post date:** [July 19, 2022, 5:43am UTC](https://forums.developer.nvidia.com/t/how-to-release-all-gpu-memory-after-saving-built-engine/221038/4 "2022-07-19T05:43:54Z")

</div>

Hi,

Could you please share with us a minimal issue repro scrip and model for better debugging.

Other allocations like from libraries (Cuda Context, cudnn, cublas, etc.). They are not avoidable.  
After cublas, cudnn loaded, some host and device memory are reserved and will not be released until you dlclose the library or exit the process (some might be for GPU kernels, some might be for kernel management in host …).

For cuda context, cudnn and cublas, the memory allocation start from your first API call to the library, and released only after you unload this library, there is no explicit API to release these memories.

Thank you.
