d8ahazard / sd_dreambooth_extension

Other
1.85k stars 283 forks source link

[Bug]: Failing to install newer version of xformers #1426

Closed dege1000 closed 5 months ago

dege1000 commented 6 months ago

Is there an existing issue for this?

What happened?

The install script fails to install the needed version of xformers and falls back using the one provided by WebUi due to a couple of issues. I'm running on arch and my WebUi is: version: v1.7.0  •  python: 3.11.6  •  torch: 2.0.1+cu118  •  xformers: 0.0.20  •  gradio: 3.41.2  •  checkpoint: 6f80073c93 First it fails with no such option: --index-url https://download.pytorch.org/whl/cu118, which can be fixed by replacing in postisntall.py line 191 --index-url with -i After that is resolved it fails with: Error occurred: Looking in indexes: https://download.pytorch.org/whl/cu118 WARNING: Location ' https://download.pytorch.org/whl/cu118/xformers/' is ignored: it is either a non-existing path or lacks a specific scheme. ERROR: Could not find a version that satisfies the requirement xformers==0.0.21 (from versions: none) ERROR: No matching distribution found for xformers==0.0.21 WARNING: There was an error checking the latest version of pip.. Entering the url in a browser shows that xformers is only available from version 0.0.22 and up.

Steps to reproduce the problem

  1. Install Dreambooth form the extensions tab
  2. Restart WebUi
  3. Issues ocurs on install of requirements

Commit and libraries

Dreambooth revision: 22e5440e15eea1be6c8f8ce407d2d8c273b2cc9c Checking bitsandbytes... Checking bitsandbytes (Linux) Checking Dreambooth requirements... [Dreambooth] accelerate v0.21.0 is already installed. [Dreambooth] dadaptation v3.1 is already installed. [Dreambooth] diffusers v0.23.1 is already installed. [Dreambooth] discord-webhook v1.3.0 is already installed. [Dreambooth] fastapi is already installed. [Dreambooth] gitpython v3.1.40 is already installed. [Dreambooth] pytorch_optimizer v2.12.0 is already installed. [Dreambooth] Pillow is already installed. [Dreambooth] tqdm is already installed. [Dreambooth] tomesd v0.1.2 is already installed. [Dreambooth] tensorboard v2.13.0 is already installed. [!] xformers version 0.0.20 installed. [+] torch version 2.0.1+cu118 installed. [+] torchvision version 0.15.2+cu118 installed. [+] accelerate version 0.21.0 installed. [+] diffusers version 0.24.0 installed. [+] bitsandbytes version 0.41.2.post2 installed.

Command Line Arguments

--xformers --medvram --listen --enable-insecure-extension-access

Console logs

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye), Fedora 34+ and openSUSE Leap 15.4 or newer.
################################################################

################################################################
Running on **** user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Using TCMalloc: libtcmalloc_minimal.so.4
Python 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801]
Version: v1.7.0
Commit hash: cf2772fab0af5573da775e7437e6acdca424f26e
If submitting an issue on github, please provide the full startup log for debugging purposes.

Initializing Dreambooth
Dreambooth revision: 22e5440e15eea1be6c8f8ce407d2d8c273b2cc9c
Checking xformers...
Installing xformers
Detected torch version 2.0.1+cu118
Installing xformers from PyPI
Error occurred: Looking in indexes: https://download.pytorch.org/whl/cu118
WARNING: Location ' https://download.pytorch.org/whl/cu118/xformers/' is ignored: it is either a non-existing path or lacks a specific scheme.
ERROR: Could not find a version that satisfies the requirement xformers==0.0.21 (from versions: none)
ERROR: No matching distribution found for xformers==0.0.21
WARNING: There was an error checking the latest version of pip.

Checking bitsandbytes...
Checking bitsandbytes (Linux)
Checking Dreambooth requirements...
[Dreambooth] accelerate v0.21.0 is already installed.
[Dreambooth] dadaptation v3.1 is already installed.
[Dreambooth] diffusers v0.23.1 is already installed.
[Dreambooth] discord-webhook v1.3.0 is already installed.
[Dreambooth] fastapi is already installed.
[Dreambooth] gitpython v3.1.40 is already installed.
[Dreambooth] pytorch_optimizer v2.12.0 is already installed.
[Dreambooth] Pillow is already installed.
[Dreambooth] tqdm is already installed.
[Dreambooth] tomesd v0.1.2 is already installed.
[Dreambooth] tensorboard v2.13.0 is already installed.
[!] xformers version 0.0.20 installed.
[+] torch version 2.0.1+cu118 installed.
[+] torchvision version 0.15.2+cu118 installed.
[+] accelerate version 0.21.0 installed.
[+] diffusers version 0.24.0 installed.
[+] bitsandbytes version 0.41.2.post2 installed.
Launching Web UI with arguments: --xformers --medvram --listen --enable-insecure-extension-access
Running on local URL:  http://0.0.0.0:7860
Loading weights [6f80073c93] from ****
Creating model from config: ****
To create a public link, set `share=True` in `launch()`.
Startup time: 18.6s (prepare environment: 10.3s, import torch: 2.0s, import gradio: 0.7s, setup paths: 1.4s, initialize shared: 0.1s, other imports: 0.2s, load scripts: 2.2s, create ui: 1.1s, gradio launch: 0.4s).

Additional information

Correction: I just found out a solution: Using -f or --find-links instead of --index-url in postinstall.py will fix both issues and the script will install the required xformers version.

morphinapg commented 6 months ago

I tried your solution but it didn't work for me. I also tried manually upgrading xformers with pip but then it gave me another error:

RuntimeError: Torch is not able to use GPU

morphinapg commented 6 months ago

Okay I was able to fix it by installing this specific file from the venv:

https://files.pythonhosted.org/packages/94/fe/e091cdf2f6fa0e529db3e8756059a861062e3430753be95f285293ce26de/xformers-0.0.21-cp310-cp310-win_amd64.whl

Other versions located here:

https://pypi.org/project/xformers/0.0.21/#files

morphinapg commented 6 months ago

Unfortunately, it still appears to be training as slowly as ever. With the older version of dreambooth, from before the redesigned UI, I get about 3 it/s. With the newer version, I'm getting about 2.2 it/s, even with the correct xformers installed. Either it's not using xformers properly, or there's something else in the recent updates that's causing a performance degradation.

dege1000 commented 6 months ago

That seems to be a completely different issue. But something that comes to mind is that windows update will always try to replace the graphics driver and it usually is a much older version or a bugged one, and maybe dreambooth or torch needs a newer one. In terms of performance, I can't really tell you anything since this is the first time I installed Dreambooth and haven't trained anything yet. My issue was purely a issue with PIP not having the correct flags or my installed version of PIP bugging out.

morphinapg commented 6 months ago

That seems to be a completely different issue. But something that comes to mind is that windows update will always try to replace the graphics driver and it usually is a much older version or a bugged one, and maybe dreambooth or torch needs a newer one. In terms of performance, I can't really tell you anything since this is the first time I installed Dreambooth and haven't trained anything yet. My issue was purely a issue with PIP not having the correct flags or my installed version of PIP bugging out.

I'm using the latest driver as per Geforce Experience, and using the same driver version on both the older and newer versions of dreambooth. I tested them both today.

I figured it have been relevant because I was having this same level of performance when I was using xformers 0.0.20, and the current version of the extension wasn't allowing me to choose xformers in the UI. Once I was able to install 0.0.21, I was able to choose xformers in the UI, but performance was still the same slower level it was before.

dege1000 commented 6 months ago

Ah, as far as I know the difference between versions is not in performance but rather in precision and/or available features

d8ahazard commented 6 months ago

So, there are several things going on here, I think, that are mostly out of my control:

  1. The xformers version you can use is dependent on OS, Torch version, and a few other things, but as long as it's >= 0.0.20, it should be fine.

  2. AUTO, in his infinite wisdom, decided to make it really REALLY hard to use any other xformers version. Apparently, you maybe can try setting --skip-version-check, which, according to the docs, enables "Do not check versions of torch and xformers".

  3. As such, I'll probably just roll back to 0.0.20. Also, you need to have --xformers specified in your commandline args, else auto will completely break it, everywhere.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days