[Bug]: Mac M1 Install does not work correctly
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 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.
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.shto add a line that tries to install the required dependencies withpip install -r requirements.txteach 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 deactivateOriginally 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.txtdidn't work for them, or finding that despitepip installing the individual requirements they still don't seem to 'be there', it might be an issue with yourcondaenvironment, and whichpipis 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/pipAnd not something like:
/opt/conda/envs/web-ui/bin/pip /opt/conda/bin/pipThen you can likely fix it by either doing a
conda install pipthen usingpipas normal, or usingpython -m pip install FOOinstead of usingpipdirectly.Originally posted by @0xdevalias in https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/4109#issuecomment-1308357941
I did a
conda install pipand then usedpython -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.txtrather thanrequirements.txt?python -m pip install -r requirements_versions.txtOriginally 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
@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
Closing as stale.