Skip to content

[bug]: free_gpu_mem does not offload diffusers models #2326

@keturn

Description

@keturn

To Do

Traceback (most recent call last):
  File "InvokeAI/backend/invoke_ai_web_server.py", line 1216, in generate_images
    self.generate.prompt2image(
  File "InvokeAI/ldm/generate.py", line 463, in prompt2image
    if self.free_gpu_mem and self.model.cond_stage_model.device != self.model.device:
AttributeError: 'WeightedPromptFragmentsToEmbeddingsConverter' object has no attribute 'device'

Additional context

I think there are a couple different memory-related flags?

If this is the one that just forces garbage collection before doing the decode, I think that's cheap enough to do that we might as well always do it and spare the trouble of documenting a configuration flag for it.

But do we also have some other flag that should be mapped to the diffusers sequential CPU offload option?

Update: No, those weren't separate things in Invoke, free_gpu_mem did both, so that's the option to map to sequential CPU offload.

if self.free_gpu_mem:
self.model.model.to('cpu')
self.model.cond_stage_model.device = 'cpu'
self.model.cond_stage_model.to('cpu')
gc.collect()
torch.cuda.empty_cache()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions