diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

device_map='balanced' pipe.load_textual_inversion() function error

Open Honey-666 opened this issue 1 year ago • 2 comments

hi https://github.com/huggingface/diffusers/blob/b934215d4c376ea2e08e28103443686b95ea772c/src/diffusers/loaders/textual_inversion.py#L458

The code at this reference does not seem to handle device_map='balanced' and will report an error

error msg:

diffusers\src\diffusers\pipelines\pipeline_utils.py", line 1130, in enable_sequential_cpu_offload
   raise ValueError(
ValueError: It seems like you have activated a device mapping strategy on the pipeline so calling `enable_sequential_cpu_offload() isn't allowed. You can call `reset_device_map()` first and then call `enable_sequential_cpu_offload()`.

os:

diffusers==diffusers-0.28.0.dev0

this is my code:

pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5",
    variant="fp16",
    safety_checker=None,
    torch_dtype=torch.float16).to('cuda')


pipe.load_textual_inversion(EasyNegative.pt,
                            easynegative,
                            device_map='balanced',
                            torch.float16)

@sayakpaul

Honey-666 avatar May 11 '24 01:05 Honey-666

Thanks for reporting. Does https://github.com/huggingface/diffusers/pull/7919 solve the problem for you?

sayakpaul avatar May 11 '24 19:05 sayakpaul

Thanks for reporting. Does #7919 solve the problem for you?

Yes, it solved my problem and I passed the test successfully, thank you very much

Honey-666 avatar May 13 '24 03:05 Honey-666

closing as fixed by @sayakpaul !

yiyixuxu avatar May 13 '24 19:05 yiyixuxu