When a torch.OutOfMemoryError: CUDA out of memory exception occurs during generation, the application becomes blocking for new generation.
Expected behaviour:
- Catch the exception.
- Show a modal error dialog with a short message.
- Reset the UI state to “idle” so the user can start a new generation without restarting the program.
Relevant code locations (for context):
src/genui/operations.py – ImageGenerationOperation.generate_image – the actual inference call.
src/genui/ui_widgets/window_mixins/generation_command.py – UI entry points that disable buttons and start the worker.
src/genui/main.py – Window.show_error_modal_dialog – already exists, can be reused.
Exception:
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 20.00 MiB. GPU 0 has a total capacity of 7.65 GiB of which 25.19 MiB is free. Including non-PyTorch memory, this process has 1.40 GiB memory in use. Of the allocated memory 1.19 GiB is allocated by PyTorch, and 109.31 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
When a
torch.OutOfMemoryError: CUDA out of memoryexception occurs during generation, the application becomes blocking for new generation.Expected behaviour:
Relevant code locations (for context):
src/genui/operations.py–ImageGenerationOperation.generate_image– the actual inference call.src/genui/ui_widgets/window_mixins/generation_command.py– UI entry points that disable buttons and start the worker.src/genui/main.py–Window.show_error_modal_dialog– already exists, can be reused.Exception: