From 65fbefd0337f9deb913c6956a9cfe2155c9c2f5b Mon Sep 17 00:00:00 2001 From: xeonvs Date: Wed, 7 Sep 2022 15:58:25 +0200 Subject: Added support for launching on Apple Silicon --- modules/shared.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'modules/shared.py') 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 -- cgit v1.2.1