diff options
author | brkirch <brkirch@users.noreply.github.com> | 2022-12-03 07:28:53 +0000 |
---|---|---|
committer | brkirch <brkirch@users.noreply.github.com> | 2022-12-03 11:44:59 +0000 |
commit | 5ec8981df46ff6e678c09dd2c1bf4d873ac22a46 (patch) | |
tree | 5b1f13cb4e42ec35ab7a103fbce7148365bc22b6 | |
parent | bef36597cc46671eeb2041b0343bd5e183883eb7 (diff) | |
download | stable-diffusion-webui-gfx803-5ec8981df46ff6e678c09dd2c1bf4d873ac22a46.tar.gz stable-diffusion-webui-gfx803-5ec8981df46ff6e678c09dd2c1bf4d873ac22a46.tar.bz2 stable-diffusion-webui-gfx803-5ec8981df46ff6e678c09dd2c1bf4d873ac22a46.zip |
Revert most launch.py changes, add mac user script
Adds an addition file to read environment variables from when the webui.sh is run from macOS.
-rw-r--r-- | launch.py | 19 | ||||
-rw-r--r-- | webui-macos-env.sh | 13 | ||||
-rwxr-xr-x | webui.sh | 8 |
3 files changed, 22 insertions, 18 deletions
@@ -194,20 +194,6 @@ def prepare_enviroment(): xformers = '--xformers' in sys.argv
ngrok = '--ngrok' in sys.argv
- if platform.system() == 'Darwin':
- os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
- torch_command = os.environ.get('TORCH_COMMAND', "pip install torch==1.12.1 torchvision==0.13.1")
- k_diffusion_repo = os.environ.get('K_DIFFUSION_REPO', 'https://github.com/brkirch/k-diffusion.git')
- k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "51c9778f269cedb55a4d88c79c0246d35bdadb71")
- if os.environ.get('COMMANDLINE_ARGS') == None:
- if '--use-cpu' in sys.argv:
- idx = sys.argv.index('--use-cpu')
- if idx < len(sys.argv) and sys.argv[idx+1][0] != '-':
- sys.argv.insert(idx+1, 'interrogate')
- else:
- sys.argv += ['--use-cpu', 'interrogate']
- sys.argv.append('--no-half')
-
try:
commit = run(f"{git} rev-parse HEAD").strip()
except Exception:
@@ -219,7 +205,7 @@ def prepare_enviroment(): if not is_installed("torch") or not is_installed("torchvision"):
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch")
- if not skip_torch_cuda_test and platform.system() != 'Darwin':
+ if not skip_torch_cuda_test:
run_python("import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'")
if not is_installed("gfpgan"):
@@ -246,9 +232,6 @@ def prepare_enviroment(): if not is_installed("pyngrok") and ngrok:
run_pip("install pyngrok", "ngrok")
- if platform.system() == 'Darwin' and not is_installed("psutil"):
- run_pip("install psutil", "psutil")
-
os.makedirs(dir_repos, exist_ok=True)
git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
diff --git a/webui-macos-env.sh b/webui-macos-env.sh new file mode 100644 index 00000000..68d1f754 --- /dev/null +++ b/webui-macos-env.sh @@ -0,0 +1,13 @@ +#!/bin/bash +#################################################################### +# macOS defaults # +# Please modify webui-user.sh to change these instead of this file # +#################################################################### + +export COMMANDLINE_ARGS="--skip-torch-cuda-test --no-half --use-cpu interrogate" +export TORCH_COMMAND="pip install torch==1.12.1 torchvision==0.13.1" +export K_DIFFUSION_REPO="https://github.com/brkirch/k-diffusion.git" +export K_DIFFUSION_COMMIT_HASH="51c9778f269cedb55a4d88c79c0246d35bdadb71" +export PYTORCH_ENABLE_MPS_FALLBACK=1 + +#################################################################### @@ -4,6 +4,14 @@ # change the variables in webui-user.sh instead # ################################################# +# If run from macOS, load defaults from webui-macos-env.sh +if [[ "$OSTYPE" == "darwin"* ]]; then + if [[ -f webui-macos-env.sh ]] + then + source ./webui-macos-env.sh + fi +fi + # Read variables from webui-user.sh # shellcheck source=/dev/null if [[ -f webui-user.sh ]] |