lshqqytiger / stable-diffusion-webui-amdgpu

Stable Diffusion web UI
GNU Affero General Public License v3.0
1.8k stars 186 forks source link

[Bug]: Can't optimize ONNX models with olive: 'ONNXStableDiffusionModel' object has no attribute 'lowvram' #341

Open DaveyDangerousDavid opened 9 months ago

DaveyDangerousDavid commented 9 months ago

Checklist

What happened?

When I click on "optimize model using Olive" it throws an error: AttributeError: 'ONNXStableDiffusionModel' object has no attribute 'lowvram'

Steps to reproduce the problem

What should have happened?

onnx model should have been optimized with olive for use.

What browsers do you use to access the UI ?

Brave

Sysinfo

system-info-12-25-23.json

Console logs

---
*** Error completing request
*** Arguments: ('Lykon/dreamshaper-7', '', 'vae', 'dreamshaper-7', 'dreamshaper-7', 'runwayml/stable-diffusion-v1-5', '', 'vae', 'stable-diffusion-v1-5', 'stable-diffusion-v1-5', True, True, True, True, True, False, True, True, True, True, 'euler', True, 512, False, '', '', '') {}
    Traceback (most recent call last):
      File "J:\python\Automatic\stable-diffusion-webui-directml\modules\call_queue.py", line 57, in f
        res = list(func(*args, **kwargs))
      File "J:\python\Automatic\stable-diffusion-webui-directml\modules\call_queue.py", line 36, in f
        res = func(*args, **kwargs)
      File "J:\python\Automatic\stable-diffusion-webui-directml\modules\ui.py", line 1759, in optimize
        return optimize_sd_from_ckpt(
      File "J:\python\Automatic\stable-diffusion-webui-directml\modules\sd_olive_ui.py", line 67, in optimize_sd_from_ckpt
        unoptimized_dir, optimized_dir = ready(unoptimized_dir, optimized_dir)
      File "J:\python\Automatic\stable-diffusion-webui-directml\modules\sd_olive_ui.py", line 35, in ready
        unload_model_weights(shared.sd_model)
      File "J:\python\Automatic\stable-diffusion-webui-directml\modules\sd_models.py", line 881, in unload_model_weights
        send_model_to_cpu(sd_model or shared.sd_model)
      File "J:\python\Automatic\stable-diffusion-webui-directml\modules\sd_models.py", line 632, in send_model_to_cpu
        if m.lowvram:
      File "J:\python\Automatic\stable-diffusion-webui-directml\venv\lib\site-packages\torch\nn\modules\module.py", line 1269, in __getattr__
        raise AttributeError("'{}' object has no attribute '{}'".format(
    AttributeError: 'ONNXStableDiffusionModel' object has no attribute 'lowvram'

---

Additional information

AMD 6900xt Fresh install. can use cpu models fine using the cpu but trying to use gpu can't optimize models for use.

DaveyDangerousDavid commented 9 months ago

https://www.youtube.com/watch?v=mKxt0kxD5C0 temp found a fix

lshqqytiger commented 9 months ago

It works for me now. Please test with latest commits again.