LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   I believe I'm having a python related problem when trying to setup xformers for stable diffusion (https://www.linuxquestions.org/questions/programming-9/i-believe-im-having-a-python-related-problem-when-trying-to-setup-xformers-for-stable-diffusion-4175719726/)

wh33t 12-13-2022 11:15 AM

I believe I'm having a python related problem when trying to setup xformers for stable diffusion
 
Would anyone be able to she some light on what issue Python is having here and how I might go about fixing it?

I am trying to get the xformers library installed into stable-diffusion and I cannot seem to make it work. I am pretty sure it's related to me using Linux Mint and perhaps the wrong python version.

Code:

(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-e730ilkj/xformers_2804a3da417644c5a5451c004d0ea051/setup.py", line 239, in <module>
          ext_modules=get_extensions(),
        File "/tmp/pip-install-e730ilkj/xformers_2804a3da417644c5a5451c004d0ea051/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$

Any tips greatly appreciated. I have searched around and tried many things to fix this but cannot seem to get it working.

pan64 12-13-2022 12:24 PM

probably this? https://github.com/AUTOMATIC1111/sta...ent-1276993118

wh33t 12-13-2022 01:28 PM

Quote:

Originally Posted by pan64 (Post 6397649)

Code:

(venv) wh33t@wh33tbox:~/stable-diffusion-webui$ sudo pip3 install git+https://github.com/facebookresearch/xformers.git#egg=xformers
[sudo] password for wh33t:                 
sudo: pip3: command not found
(venv) wh33t@wh33tbox:~/stable-diffusion-webui$

I've pretty much tried all the first 3 pages of google search results. None of them "just fix" the issue, which is why I'm trying to understand what the actual underlying problem is. I believe it's related specifically to Linux Mint and how it uses Python.

pan64 12-13-2022 03:28 PM

no, it is not linux mint, but a python or xformers related issue.
You can try python3 -m pip install .... instead of pip3 install. Or just you need to install pip3. (python3-pip or something similar is the name of the package)

wh33t 12-13-2022 03:51 PM

Quote:

Originally Posted by pan64 (Post 6397673)
no, it is not linux mint, but a python or xformers related issue.
You can try python3 -m pip install .... instead of pip3 install. Or just you need to install pip3. (python3-pip or something similar is the name of the package)

So the automatic1111 stable diffusion setup is just flawed like this?

I will try to install pip3.

wh33t 12-13-2022 03:55 PM

Quote:

Originally Posted by pan64 (Post 6397673)
no, it is not linux mint, but a python or xformers related issue.
You can try python3 -m pip install .... instead of pip3 install. Or just you need to install pip3. (python3-pip or something similar is the name of the package)

I installed pip3 as suggested. Here is the output now

Code:

(venv) wh33t@wh33tbox:~/stable-diffusion-webui$ sudo pip3 install git+https://github.com/facebookresearch/xformers.git#egg=xformers
Collecting xformers
  Cloning https://github.com/facebookresearch/xformers.git to /tmp/pip-install-msdzlpgi/xformers_7aaee2db4dbc422e86932e9f70da646b
  Running command git clone --filter=blob:none --quiet https://github.com/facebookresearch/xformers.git /tmp/pip-install-msdzlpgi/xformers_7aaee2db4dbc422e86932e9f70da646b
  Resolved https://github.com/facebookresearch/xformers.git to commit 7835679ed1d91837de3b2e0391098469a8a8b6d6
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
 
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 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-msdzlpgi/xformers_7aaee2db4dbc422e86932e9f70da646b/setup.py", line 20, in <module>
          import torch
      ModuleNotFoundError: No module named 'torch'
      [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$

I presume torch is referring to pytorch? I'm pretty sure I have that setup already.

Update: I ran the same command again without using sudo and it seemed to install. But it still errors using when I try to launch it with xformers.

I've got a post over the Mint Forums, so at least I know I'm not the only one and I do think this is somehow related to Linuxmint.

pan64 12-14-2022 12:46 AM

just one comment: using pip as root and as user are different: it will use a different repo (or venv). That's why probably I would try to sudo pip3 install torch.


All times are GMT -5. The time now is 08:17 PM.