I need help with a transformers error

Im trying to use the stable-diffusion webui with the dreambooth extension on my windows pc, but I keep getting this error

ImportError: diffusers requires transformers >= 4.25.1 to function correctly, but 4.21.0 was found in your environment. You can upgrade it with pip: 'pip install transformers --upgrade'

but when I use the pip install transformers --upgrade command, it says I already have version 4.25.1

Same issue here. It seems itā€™s a bug or something.

I have the same issue

same here! Anyone found a solution? Iā€™m on OSX M1

I started having the same issue out of nowhere today as well. I have no clue what Iā€™m doing though so Iā€™m glad Iā€™m not the only one experiencing this. Also my dreambooth extension no longer shows up as a resultā€¦is that everyone elseā€™s issue also?

Yeah, having the same. I tried to update the requirements.txt to reflect the higher version but it did not trigger an update when executing the batā€¦

what version of diffusers is installed? I had to downgrade to 0.9.0 to get my system working today.

Here is the solution, until theyā€™ll come up with some official one, it is very important to keep tabs consistent and the same!!!:

  1. Open launch.py with text editor
    find this line and the next line:
xformers = '--xformers' in sys.argv
ngrok = '--ngrok' in sys.argv

add this after

    skipUpdate = '--skip' in sys.argv
  1. find this line (skip to point 4 for full code)
git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)

add this before it:

if not skipUpdate:
  1. find this:
 if update_check:
            version_check(commit)

add after:

    else:
        print("Skipping updates...")

you need to tab everything inside

  1. the whole section will look like this (copy and replace this part):
Full code after replacement, copy with spaces and tabs!
    if not skipUpdate:
        git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
        git_clone(taming_transformers_repo, repo_dir('taming-transformers'), "Taming Transformers", taming_transformers_commit_hash)
        git_clone(k_diffusion_repo, repo_dir('k-diffusion'), "K-diffusion", k_diffusion_commit_hash)
        git_clone(codeformer_repo, repo_dir('CodeFormer'), "CodeFormer", codeformer_commit_hash)
        git_clone(blip_repo, repo_dir('BLIP'), "BLIP", blip_commit_hash)

        if not is_installed("lpips"):
            run_pip(f"install -r {os.path.join(repo_dir('CodeFormer'), 'requirements.txt')}", "requirements for CodeFormer")
        
        run_pip(f"install -r {requirements_file}", "requirements for Web UI")
        
        run_extensions_installers(settings_file=args.ui_settings_file)
        
        if update_check:
            version_check(commit)
    else:
        print("Skipping updates...")
  1. Open this file: modules/shared.py and find this line:
parser.add_argument("--xformers", action='store_true', help="enable xformers for cross attention layers")

add this line bellow

parser.add_argument("--skip", action='store_true', help="skip updates")
  1. save everything

  2. now open up a cmd window in the stable-diffusion folder and type
    venv\Scripts\activate.bat

  3. type this command next:
    pip install transformers --upgrade

  4. now lunch webui.bat with argument --skip to skip updates (downgrades) to transformers

It will download some new weights (~2GB), not sure what module is updating, probably dreambooth
Also --skip will make it start faster, skips downloading/checking for updates


Edit: Found the updated file
C:\Users\XXXX.cache\huggingface\hub\modelsā€“openaiā€“clip-vit-large-patch14\snapshots\8d052a0f05efbaefbc9e8786ba291cfdf93e5bff\pytorch_model.bin

Looks like itā€™s the CLIP model probably updated, not sure

1 Like

Thanks for this but I am having an issue and my python skills really suckā€¦

Traceback (most recent call last):
  File "C:\Users\nbock\Documents\AI\stable-diffusion-webui\launch.py", line 238, in <module>
    if not skipUpdate:
NameError: name 'skipUpdate' is not defined

But I have added ā€œskipUpdate = ā€˜ā€“skipā€™ in sys.argvā€ in line 197 under ngrokā€¦
Iā€™d say that variable is defined :smiley: but python disagrees :))

Any idea?

Spider853, that didnā€™t help :frowning:

venv "C:\Projects\Stable Diffusion\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 44c46f0ed395967cd3830dd481a2db759fda5b3b
Skipping updates...
Launching Web UI with arguments: --xformers --force-enable-xformers --skip
Error loading script: api.py
Traceback (most recent call last):
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\modules\scripts.py", line 184, in load_scripts
    module = script_loading.load_module(scriptfile.path)
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\modules\script_loading.py", line 13, in load_module
    exec(compiled, module.__dict__)
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\extensions\sd_dreambooth_extension\scripts\api.py", line 9, in <module>
    from extensions.sd_dreambooth_extension.dreambooth import dreambooth
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dreambooth.py", line 9, in <module>
    from diffusers.utils import logging as dl
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\venv\lib\site-packages\diffusers\__init__.py", line 26, in <module>
    raise ImportError(
ImportError: `diffusers` requires transformers >= 4.25.1 to function correctly, but 4.21.0 was found in your environment. You can upgrade it with pip: `pip install transformers --upgrade`

Error loading script: main.py
Traceback (most recent call last):
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\modules\scripts.py", line 184, in load_scripts
    module = script_loading.load_module(scriptfile.path)
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\modules\script_loading.py", line 13, in load_module
    exec(compiled, module.__dict__)
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\extensions\sd_dreambooth_extension\scripts\main.py", line 3, in <module>
    from extensions.sd_dreambooth_extension.dreambooth import dreambooth
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dreambooth.py", line 13, in <module>
    from extensions.sd_dreambooth_extension.dreambooth.utils import reload_system_models, unload_system_models, printm, \
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\utils.py", line 12, in <module>
    from diffusers import StableDiffusionPipeline, EulerAncestralDiscreteScheduler
  File "C:\Projects\Stable Diffusion\stable-diffusion-webui\venv\lib\site-packages\diffusers\__init__.py", line 26, in <module>
    raise ImportError(
ImportError: `diffusers` requires transformers >= 4.25.1 to function correctly, but 4.21.0 was found in your environment. You can upgrade it with pip: `pip install transformers --upgrade`

LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Loading weights [06c50424] from C:\Projects\Stable Diffusion\stable-diffusion-webui\model.ckpt
Applying xformers cross attention optimization.
Model loaded.
Loaded a total of 0 textual inversion embeddings.
Embeddings:
Running on local URL:  http://127.0.0.1:7861

To create a public link, set `share=True` in `launch()`.

Looks like even venv\Scripts\activate.bat and pip install transformers --upgrade didnā€™t update transformers. I even tried pip install transformers==4.25.1 No luckā€¦

It automatically reinstalls it back to previous version during start-up: Installing requirements for Web UI

Could you please update the "Installing requirements " scripts of Web UI to not force install a version of transformers? Does someone have a link to the ā€œautomaticā€ installation file?

@anton-l is doing a patch release now so that the scripts will work as expected. Should be ready in 1 hour.

In general, though - I donā€™t think itā€™s a good idea to force install versions upon launch. The user should IMO have control over the installation of the different versions.

1 Like

Here are the files Iā€™ve edited locally fix.zip - Google Drive

1 Like

did you actually patched the py files? Iā€™m actually using that locally without any issues, and it starts faster.
Make sure to launch with skip parameter: webui.bat --skip

1 Like

If you getting this error on the Stable Diffusion WebUI then itā€™s because your Dreambooth extension is outdated. You need to run a update on your extensions.

First do a git pull on Stable Diffusion web-gui for good measure.

Then start SD and go to extensions tab and click on Check for Updates button. It will run a check on each extension you have installed. If itā€™s outdated it will list as ā€œbehindā€ with a ticked tick box.

Now Apply and Restart should restart the web-gui and start the updates but mine didnā€™t closing the console windows and re-running the bat file to start Stable Diffusion started the update process.