You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AttributeError: 'StableDiffusionXLPipeline' object has no attribute 'final_offload_hook' #5054
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/local/lib/python3.10/site-packages/diffusers/configuration_utils.py", line 137, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'StableDiffusionXLPipeline' object has no attribute 'final_offload_hook'
To be honest I'm not sure whether it is necessary... It's a piece of code I have inherited from someone else. What the code does:
Load ControlNet models
Offload ControlNet models to CPU
Instantiate SDXL ControlNet Pipeline
# [...]controlnets=ControlNetModel.from_pretrained(os.getenv(model_path), torch_dtype=torch.float16)
cpu_offload_with_hook(controlnets)
# [...]pipeline=StableDiffusionXLControlNetPipeline(controlnet=controlnets, **default_pipeline.components)
pipeline.final_offload_hook=default_pipeline.final_offload_hook# default_pipeline is my StableDiffusionXLPipeline here
What I know is that it used to work and now it does not anymore... but maybe I can just remove pipeline.final_offload_hook = default_pipeline.final_offload_hook ?
After using enable_model_cpu_offload() I don't think you will have the need to access any of these attributes actually. We recently refactored the enable_model_cpu_offload() API to make it generally available for all the pipeline inherited from DiffusionPipeline, so, that might have broken the behaviour you are referring to. Cc: @patrickvonplaten too.
Activity
sayakpaul commentedon Sep 15, 2023
Why are you accessing
pipeline.final_offload_hook?alexisrolland commentedon Sep 15, 2023
To be honest I'm not sure whether it is necessary... It's a piece of code I have inherited from someone else. What the code does:
What I know is that it used to work and now it does not anymore... but maybe I can just remove
pipeline.final_offload_hook = default_pipeline.final_offload_hook?sayakpaul commentedon Sep 15, 2023
After using
enable_model_cpu_offload()I don't think you will have the need to access any of these attributes actually. We recently refactored theenable_model_cpu_offload()API to make it generally available for all the pipeline inherited fromDiffusionPipeline, so, that might have broken the behaviour you are referring to. Cc: @patrickvonplaten too.alexisrolland commentedon Sep 17, 2023
Got it, thank you @sayakpaul. I'll just drop the
final_offload_hookand close this issue.alexisrolland commentedon Oct 5, 2023
I think dropping the
final_offload_hookis what triggered these errors: #5281It seems the hooks of ControlNet pipeline are not properly synced with the main pipeline.