# Need to clear GPU memory

**URL:** <https://numba.discourse.group/t/need-to-clear-gpu-memory/2738>\
**Category:** Development\
**Created:** [September 20, 2024, 8:25am UTC](https://numba.discourse.group/t/need-to-clear-gpu-memory/2738 "2024-09-20T08:25:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![srujan](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/srujan/32/1134_2.png) [@srujan](https://numba.discourse.group/u/srujan)\
**Post date:** [September 20, 2024, 8:25am UTC](https://numba.discourse.group/t/need-to-clear-gpu-memory/2738/1 "2024-09-20T08:25:40Z")

</div>

I’m performing mathematical calculations using Numba and creating a `cuda.local.array` within my CUDA kernels. After completing the computations, I call `cuda.current_context().reset()` to clear the cache. While this reduces the memory usage by 500 MB, there is still a significant amount of GPU memory that remains occupied.

I need to completely free this memory for further GPU computations. If I use `cuda.close()`, I lose the context, which leads to a `CudaAPIError: [400] Call to cuLaunchKernel results in CUDA_ERROR_INVALID_HANDLE` error when I try to execute any Numba code afterward.

How can I effectively clear all GPU memory without losing the context?
