stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: Mac M1 Install does not work correctly

Open enzyme69 opened this issue 3 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

Traceback (most recent call last):
  File "/Users/blendersushi/Documents/stable-diffusion-webui/webui.py", line 13, in <module>
    from modules import devices, sd_samplers, upscaler, extensions, localization
  File "/Users/blendersushi/Documents/stable-diffusion-webui/modules/sd_samplers.py", line 8, in <module>
    import k_diffusion.sampling
  File "/Users/blendersushi/Documents/stable-diffusion-webui/repositories/k-diffusion/k_diffusion/__init__.py", line 1, in <module>
    from . import augmentation, config, evaluation, external, gns, layers, models, sampling, utils
  File "/Users/blendersushi/Documents/stable-diffusion-webui/repositories/k-diffusion/k_diffusion/external.py", line 6, in <module>
    from . import sampling, utils
  File "/Users/blendersushi/Documents/stable-diffusion-webui/repositories/k-diffusion/k_diffusion/sampling.py", line 7, in <module>
    import torchsde
ModuleNotFoundError: No module named 'torchsde'

and also:

RuntimeError: Couldn't install torch. Command: "/Users/blendersushi/Documents/stable-diffusion-webui/venv/bin/python3" -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113 Error code: 1 stdout: Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu113

stderr: ERROR: Could not find a version that satisfies the requirement torch==1.12.1+cu113 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0) ERROR: No matching distribution found for torch==1.12.1+cu113

Steps to reproduce the problem

Try installing, it does not work....

What should have happened?

Install should just work?

Commit where the problem happens

latest

What platforms do you use to access UI ?

MacOS

What browsers do you use to access the UI ?

Apple Safari

Command Line Arguments

No response

Additional information, context and logs

No response

enzyme69 avatar Nov 11 '22 09:11 enzyme69

@enzyme69 I ran into the same problem. Running the following commands in terminal fixed my install. Hope it helps! 1a) First get conda inited in the default shell of Mac OS –  conda init zsh 1b) Try to enable the conda env, just to make sure it takes. –  conda activate web-ui (If you run into issues here, go through the commands one by one in the setup_mac.sh, until you can activate the web-ui env.) 2) Once conda is properly added to your env, try to run the run_webui_mac.sh. If you're unlucky like me, it'll complain about torchsde not being found. 3) install the missing python library pip install torchsde 4) run_webui_mac.sh again and it ought to work.

timriot avatar Nov 11 '22 22:11 timriot

To fix it more sustainably, you can edit your run script as below to ensure it always keeps the dependencies updated properly:

You can modify your run_webui_mac.sh to add a line that tries to install the required dependencies with pip install -r requirements.txt each time it starts, after it pulls the latest code. This would probably make a sensible default, and is fairly quick to run, so it might be worth someone telling the original author to include it in their setup script to avoid this sort of error for end users in future:

Here is what mine looks like:

#!/usr/bin/env bash -l

pyenv local anaconda3-2022.05

# This should not be needed since it's configured during installation, but might as well have it here.
conda env config vars set PYTORCH_ENABLE_MPS_FALLBACK=1

# Activate conda environment
conda activate web-ui

# Pull the latest changes from the repo
git pull --rebase

+ # Update the dependencies if needed
+ pip install -r requirements.txt

# Run the web ui
python webui.py --deepdanbooru --precision full --no-half --use-cpu Interrogate GFPGAN CodeFormer $@

# Deactivate conda environment
conda deactivate

Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4109#issuecomment-1304747007


For the others who said that pip install -r requirements.txt didn't work for them, or finding that despite pip installing the individual requirements they still don't seem to 'be there', it might be an issue with your conda environment, and which pip is being used. Sometimes the version you're calling doesn't actually install the packages to the correct place, and so they can't be found later.

I have a new theory for you, based on this StackOverflow:

  • https://stackoverflow.com/questions/41060382/using-pip-to-install-packages-to-anaconda-environment

What do you see when you activate your conda environment, then run which -a pip?

If it's only something like:

/opt/conda/bin/pip

And not something like:

/opt/conda/envs/web-ui/bin/pip
/opt/conda/bin/pip

Then you can likely fix it by either doing a conda install pip then using pip as normal, or using python -m pip install FOO instead of using pip directly.

Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4109#issuecomment-1308357941

I did a conda install pip and then used python -m, it looked like it wasn't going to work but then I changed my run script a tiny bit,

Curious, what made you think it wasn't going to work? And what was the specific change to the run script that made it work for you? Was it using requirements_versions.txt rather than requirements.txt?

python -m pip install -r requirements_versions.txt

Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4109#issuecomment-1309356932


Hopefully the above helps people who are still running into this issue 🖤

Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4061#issuecomment-1314398808

0xdevalias avatar Nov 14 '22 21:11 0xdevalias

@enzyme69 I had the same issue as well and none of the solutions from the comments worked for me (including @0xdevalias's above).

It turns out that the issue was that I had upgraded to Python 3.12, but when I switched back to 3.10 it worked again.

Looks like PyTorch ins't supported from Python 3.11 onwards yet. Source: link

roddutra avatar Nov 17 '22 06:11 roddutra

Closing as stale.

catboxanon avatar Aug 03 '23 16:08 catboxanon