huggingface / huggingface/diffusers

pipeline fail to move to "cuda" if one of the component is PeftModel

Open
#10,403 3 comments 0 reactions 0 assignees View on GitHub
bug needs-code-example stale
Dominant language
Python
Stars
34.5k
Forks
7.3k
Avg merge
3d 3h
Merged PRs (30d)
91

Description

When I was doing infer, I loaded the pre-trained weights using the following method:
```
self.transformer = PeftModel.from_pretrained(
self.base_transformer,
lora_model_path
)
```
and loaded the pipeline in the following way:
```
pipe = FluxControlNetPipeline(transformer=transformer, ......)
```
However, I encountered an error when running it:
**ValueError**: It seems like you have activated sequential model offloading by calling `enable_sequential_cpu_offload`, but are now attempting to move the pipeline to GPU. This is not compatible with offloading. Please, move your pipeline `.to('cpu')` or consider removing the move altogether if you use sequential offloading.

Strangely, I have never manually set sequential model offloading. And I found that if I didn't call
```
self.transformer = PeftModel.from_pretrained(
self.base_transformer,
lora_model_path
)
```
Instead, directly set `self.transformer = self.base_transformer`, and the subsequent code remains unchanged, the above error will not occur.
If there's someone who has encountered the same issue?

### System Info

diffusers==0.33.0.dev0
peft==0.14.0

@yiyixuxu @sayakpaul @DN6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.