Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Mac M1 Install does not work correctly #4599

Closed
1 task done
enzyme69 opened this issue Nov 11, 2022 · 4 comments
Closed
1 task done

[Bug]: Mac M1 Install does not work correctly #4599

enzyme69 opened this issue Nov 11, 2022 · 4 comments
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance platform:mac Issues that apply to Apple OS X, M1, M2, etc

Comments

@enzyme69
Copy link

Is there an existing issue for this?

  • 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 enzyme69 added the bug-report Report of a bug, yet to be confirmed label Nov 11, 2022
@timriot
Copy link

timriot commented Nov 11, 2022

@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.

@0xdevalias
Copy link

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 #4109 (comment)


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:

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 #4109 (comment)

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 #4109 (comment)


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

Originally posted by @0xdevalias in #4061 (comment)

@roddutra
Copy link

roddutra commented Nov 17, 2022

@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

@mezotaken mezotaken added asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance and removed bug-report Report of a bug, yet to be confirmed labels Jan 30, 2023
@akx akx added the platform:mac Issues that apply to Apple OS X, M1, M2, etc label Jun 13, 2023
@catboxanon
Copy link
Collaborator

Closing as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
asking-for-help-with-local-system-issues This issue is asking for help related to local system; please offer assistance platform:mac Issues that apply to Apple OS X, M1, M2, etc
Projects
None yet
Development

No branches or pull requests

7 participants