aboutsummaryrefslogtreecommitdiffstats
path: root/modules/shared.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2022-09-07 19:29:44 +0000
committerGitHub <noreply@github.com>2022-09-07 19:29:44 +0000
commit296d012423f8d1862a63680443bb88b7d904ba4e (patch)
treef0dcc162fb3b3fa97d84d9c9ac7922203fc11df9 /modules/shared.py
parentee29bb77bfe3d2095bc08861bcdebeea20b890f1 (diff)
parentba1124b326280202cb583bbdc669fb5303bbd3e3 (diff)
downloadstable-diffusion-webui-gfx803-296d012423f8d1862a63680443bb88b7d904ba4e.tar.gz
stable-diffusion-webui-gfx803-296d012423f8d1862a63680443bb88b7d904ba4e.tar.bz2
stable-diffusion-webui-gfx803-296d012423f8d1862a63680443bb88b7d904ba4e.zip
Merge pull request #108 from xeonvs/mps-support
Added support for launching on Apple Silicon M1/M2
Diffstat (limited to 'modules/shared.py')
-rw-r--r--modules/shared.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/modules/shared.py b/modules/shared.py
index beb6f9bb..e529ec27 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -36,9 +36,12 @@ parser.add_argument("--opt-split-attention", action='store_true', help="enable o
parser.add_argument("--listen", action='store_true', help="launch gradio with 0.0.0.0 as server name, allowing to respond to network requests")
cmd_opts = parser.parse_args()
-cpu = torch.device("cpu")
-gpu = torch.device("cuda")
-device = gpu if torch.cuda.is_available() else cpu
+if torch.has_cuda:
+ device = torch.device("cuda")
+elif torch.has_mps:
+ device = torch.device("mps")
+else:
+ device = torch.device("cpu")
batch_cond_uncond = cmd_opts.always_batch_cond_uncond or not (cmd_opts.lowvram or cmd_opts.medvram)
parallel_processing_allowed = not cmd_opts.lowvram and not cmd_opts.medvram