r/pythonhelp • • Dec 13 '22

Can't get the xformers library installed into stable diffusion

I've tried a lot of different things from github and from other places on reddit but I can't seem to figure this out so I figured it was probably time to actually investigate the issue.

So when I add --xformers to the commandline_args string in launch.py (which is supposedly the way install this) it just crashes with this output.

wh33t@wh33tbox:~/stable-diffusion-webui$ source venv/bin/activate
(venv) wh33t@wh33tbox:~/stable-diffusion-webui$ python launch.py 
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
Commit hash: 685f9631b56ff8bd43bce24ff5ce0f9a0e9af490
Installing xformers
Traceback (most recent call last):
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 294, in <module>
    prepare_environment()
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 230, in prepare_environment
    run_pip("install xformers", "xformers")
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 78, in run_pip
    return run(f'"{python}" -m pip {args} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}")
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 49, in run
    raise RuntimeError(message)
RuntimeError: Couldn't install xformers.
Command: "/home/wh33t/stable-diffusion-webui/venv/bin/python" -m pip install xformers --prefer-binary
Error code: 1
stdout: Collecting xformers
  Using cached xformers-0.0.13.tar.gz (292 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'

stderr:   error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-p_qus4ba/xformers_c337561fd2d6424ab02d68796aaf774b/setup.py", line 239, in <module>
          ext_modules=get_extensions(),
        File "/tmp/pip-install-p_qus4ba/xformers_c337561fd2d6424ab02d68796aaf774b/setup.py", line 157, in get_extensions
          raise RuntimeError(
      RuntimeError: CUTLASS submodule not found. Did you forget to run `git submodule update --init --recursive` ?
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.


(venv) wh33t@wh33tbox:~/stable-diffusion-webui$

Can someone explain to me what those error messages mean? Is it because I'm using the wrong Python version or something? I don't get how this can work for so many people but not for me.

3 Upvotes

7 comments sorted by

1

u/jake-the-dog-90 Dec 13 '22

Hello, it looks like you pulled a git project that has one ( or several) submodule dependencies. Did you try running the command shown "git submodule update --init --recursive" to properly update the submodules belonging to this project? More information can be found here: https://git-scm.com/book/en/v2/Git-Tools-Submodules

1

u/wh33t Dec 13 '22

I have tried running that command before as it's mentioned in a google search I've found but it didn't fix the issue either, but maybe I need to be in a specific directory when I do it?

(venv) wh33t@wh33tbox:~/stable-diffusion-webui$ git submodule update --init --recursive~
usage: git submodule [--quiet] [--cached]
   or: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
   or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
   or: git submodule [--quiet] init [--] [<path>...]
   or: git submodule [--quiet] deinit [-f|--force] (--all| [--] <path>...)
   or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--[no-]single-branch] [--] [<path>...]
   or: git submodule [--quiet] set-branch (--default|--branch <branch>) [--] <path>
   or: git submodule [--quiet] set-url [--] <path> <newurl>
   or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
   or: git submodule [--quiet] foreach [--recursive] <command>
   or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
   or: git submodule [--quiet] absorbgitdirs [--] [<path>...]
(venv) wh33t@wh33tbox:~/stable-diffusion-webui$

1

u/jake-the-dog-90 Dec 13 '22

Did you accidently add a "~" ar the end of the command? The output shows, that it did not take the command properly. The command should be called within the project folder you pulled from github with the git clone command.

1

u/wh33t Dec 13 '22

Oh woops, I didn't mean to do that, but here is the output running it correctly.

(venv) wh33t@wh33tbox:~/stable-diffusion-webui$ git submodule update --init --recursive
(venv) wh33t@wh33tbox:~/stable-diffusion-webui$ python launch.py 
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]
Commit hash: 685f9631b56ff8bd43bce24ff5ce0f9a0e9af490
Installing xformers
Traceback (most recent call last):
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 294, in <module>
    prepare_environment()
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 230, in prepare_environment
    run_pip("install xformers", "xformers")
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 78, in run_pip
    return run(f'"{python}" -m pip {args} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}")
  File "/home/wh33t/stable-diffusion-webui/launch.py", line 49, in run
    raise RuntimeError(message)
RuntimeError: Couldn't install xformers.
Command: "/home/wh33t/stable-diffusion-webui/venv/bin/python" -m pip install xformers --prefer-binary
Error code: 1
stdout: Collecting xformers
  Using cached xformers-0.0.13.tar.gz (292 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'

stderr:   error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-4amk85eh/xformers_e34cefb6fbbf4addadc057be21c1149f/setup.py", line 239, in <module>
          ext_modules=get_extensions(),
        File "/tmp/pip-install-4amk85eh/xformers_e34cefb6fbbf4addadc057be21c1149f/setup.py", line 157, in get_extensions
          raise RuntimeError(
      RuntimeError: CUTLASS submodule not found. Did you forget to run `git submodule update --init --recursive` ?
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.


(venv) wh33t@wh33tbox:~/stable-diffusion-webui$

1

u/wh33t Dec 13 '22

Furthermore, what I really don't understand is why am I even having this issue? It seems like most people just put in --xformers into the launch script and it just works for them. Why doesn't it work for me? What could be the root cause of this issue?

1

u/generalistbloke May 01 '23

u/wh33t could you resolve the issue?

1

u/generalistbloke May 01 '23

Can someone please tell me what is the reason for this error? How can this be resolved?

The command that I used: E:\Stable Diffusion Automatic 1111\stable-diffusion-webui-master\xformers>pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers

error: subprocess-exited-with-error

× git submodule update --init --recursive -q did not run successfully.

│ exit code: 1

╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

full command: git submodule update --init --recursive -q

cwd: C:\Users\prab-zsbch1060\AppData\Local\Temp\pip-install-spxse1qe\xformers_a2aba7853c01444089734db7dce550b1

error: subprocess-exited-with-error

× git submodule update --init --recursive -q did not run successfully.

│ exit code: 1

╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Couldn't upload the entire process of the cmd prompt because of character limit.