Open potamides opened 1 month ago
To clarify more, I think the behavior I would expect would be to call the .close()
method of the generator in question immediately after it is cancelled.
Thanks for filing @potamides ! Would you like to open a PR?
Sure, if someone can give me some pointers where to look at I would be happy to do that. For starters, I tried adding something like app.iterators[event_id].iterator.close()
to the following locations, but this didn't seem to work:
Describe the bug
Resources inside generators are properly freed when the generator is exhausted. But if we cancel the generator before that happens, the resource is held until gradio exits. I would expect that the generator should get garbage collected and closed eventually (freeing resources), but it seems that there are still references to the generator object somewhere so this doesn't happen. In the provided minimum example this is not so problematic, but in my actual application tensors are not freed which will slowly lead to a Cuda OOM.
Have you searched existing issues? 🔎
Reproduction
Screenshot
No response
Logs
No response
System Info
Severity
Blocking usage of gradio