Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennyfactor/af733b03e34119c979080347b1235999 to your computer and use it in GitHub Desktop.
Save bennyfactor/af733b03e34119c979080347b1235999 to your computer and use it in GitHub Desktop.
Patches AUTOMATIC1111/stable-diffusion-webui at commit 0cc0ee1 to use gpu on 2019 macbook pro with amd radeon
From 345c4d6124b1a5802ddaafaf9f74d35a3da46758 Mon Sep 17 00:00:00 2001
From: Your Mom
Date: Sat, 4 Mar 2023 09:13:11 -0500
Subject: [PATCH] patch to run on metal for radeon macbook pro on monterey
---
macos-torch-patch.sh | 12 ++++++++++++
requirements.txt | 2 +-
webui-user.sh | 25 +++++++++++++++++++++----
3 files changed, 34 insertions(+), 5 deletions(-)
create mode 100755 macos-torch-patch.sh
diff --git a/macos-torch-patch.sh b/macos-torch-patch.sh
new file mode 100755
index 00000000..6ba7e8ad
--- /dev/null
+++ b/macos-torch-patch.sh
@@ -0,0 +1,12 @@
+echo "--- a/functional.py 2022-10-14 05:28:39.000000000 -0400
++++ b/functional.py 2022-10-14 05:39:25.000000000 -0400
+@@ -2500,7 +2500,7 @@
+ return handle_torch_function(
+ layer_norm, (input, weight, bias), input, normalized_shape, weight=weight, bias=bias, eps=eps
+ )
+- return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
++ return torch.layer_norm(input.contiguous(), normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
+
+
+ def group_norm(
+" | patch -p1 -d "$(python -c "import torch; import os; print(os.path.dirname(torch.__file__))")"/nn
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 6d53f089..62989dd5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,7 +8,7 @@ gradio==3.16.2
invisible-watermark
numpy
omegaconf
-opencv-contrib-python
+opencv-contrib-python==4.4.0.46
requests
piexif
Pillow
diff --git a/webui-user.sh b/webui-user.sh
index bfa53cb7..ab75a04d 100644
--- a/webui-user.sh
+++ b/webui-user.sh
@@ -10,10 +10,9 @@
#clone_dir="stable-diffusion-webui"
# Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention"
-#export COMMANDLINE_ARGS=""
-
+export COMMANDLINE_ARGS=" --precision full --skip-torch-cuda-test --no-half --use-cpu Interrogate GFPGAN CodeFormer"
# python3 executable
-#python_cmd="python3"
+python_cmd="python3"
# git executable
#export GIT="git"
@@ -25,7 +24,25 @@
#export LAUNCH_SCRIPT="launch.py"
# install command for torch
-#export TORCH_COMMAND="pip install torch==1.12.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113"
+export TORCH_COMMAND="pip install git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 && pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 && pip install torch==1.12.1 torchvision==0.13.1 && ./macos-torch-patch.sh"
+export PYTORCH_ENABLE_MPS_FALLBACK=1
+
+if [ -z "$PYTORCH_ENABLE_MPS_FALLBACK" ]; then
+ echo "============================================="
+ echo "====================ERROR===================="
+ echo "============================================="
+ echo "The PYTORCH_ENABLE_MPS_FALLBACK variable is not set."
+ echo "This means that the script will either fall back to CPU or fail."
+ echo "To fix this, try running the script again."
+ echo "============================================="
+ echo "====================ERROR===================="
+ echo "============================================="
+ exit 1
+else
+ echo "============================================="
+ echo "The PYTORCH_ENABLE_MPS_FALLBACK variable is set."
+ echo "============================================="
+fi
# Requirements file to use for stable-diffusion-webui
#export REQS_FILE="requirements_versions.txt"
--
2.39.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment