# Release cuda memory

**URL:** <https://discourse.itk.org/t/release-cuda-memory/7491>\
**Category:** Beginner Questions\
**Created:** [April 7, 2025, 1:35pm UTC](https://discourse.itk.org/t/release-cuda-memory/7491 "2025-04-07T13:35:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![langzhizhen](https://discourse.itk.org/user_avatar/discourse.itk.org/langzhizhen/32/4468_2.png) [@langzhizhen](https://discourse.itk.org/u/langzhizhen)\
**Post date:** [April 7, 2025, 1:35pm UTC](https://discourse.itk.org/t/release-cuda-memory/7491/1 "2025-04-07T13:35:40Z")

</div>

Hello！  
I would like to ask if there is a way to manually release cuda memory in RTK. I get “ITK ERROR: CUDA ERROR: out of memony” after running function “Update()” repeatedly. I want to manually release cuda memory that is reconstruction each epoch.  
I try following codes but it doesn’t work:

```auto
fdk.SetInput(0, output.GetOutput())
fdk.SetInput(1, pss.GetOutput())
fdk.SetGeometry(self.geometry)
fdk.GetRampFilter().SetTruncationCorrection(0.5)
fdk.GetRampFilter().SetRamLakCutFrequency(0.0)
fdk.GetRampFilter().SetHannCutFrequency(0.0) 
fdk.Update()
fdk.ReleaseDataFlagOn()

```

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [April 8, 2025, 8:28pm UTC](https://discourse.itk.org/t/release-cuda-memory/7491/2 "2025-04-08T20:28:41Z")

</div>

The CudaDataManager will release the Cuda memory as soon as it’s dirty, i.e., if the memory has been transferred to the CPU and might have been modified on the CPU side. One way to do this is to call `fdk.GetOutput().GetBufferPointer()` (as the data manager will then assume you’re likely to modify the buffer).  
But the problem you describe is probably due to a memory leak fixed since v2.6.0 ([here](https://github.com/RTKConsortium/RTK/commit/06d355709cc0273ff771b64746e008e45f5e66dd)) so you should use one of the latest wheels from the CI (downloadable as artifacts from the GitHub action, the latest is [here](https://github.com/RTKConsortium/RTK/actions/runs/14252408945)).

---

<div class="post-metadata">

**Author:** ![langzhizhen](https://discourse.itk.org/user_avatar/discourse.itk.org/langzhizhen/32/4468_2.png) [@langzhizhen](https://discourse.itk.org/u/langzhizhen)\
**Post date:** [April 11, 2025, 12:38am UTC](https://discourse.itk.org/t/release-cuda-memory/7491/3 "2025-04-11T00:38:52Z")

</div>

Yes, I find the solution in github. I have already solved my problem by installing the latest wheels from CI. Thanks!
