How to manage(clear, avoid fragments, etc) memory when run many days and more than millions loop(delete all and create all again each loop)?

the post from pytorch:
GPU RAM fragmentation diagnostics - PyTorch Forums

it’s not CUDA’s resposibility, so is there any third-party lib or official lib for this?
thanks very much!

when use CUDA-OpenGL-interop, is there any way to clear or reset all the GPU mem?