From 2f2d68e04a118df87e1cb0899ab72e9236522431 Mon Sep 17 00:00:00 2001 From: Smiril Date: Sat, 24 Sep 2022 20:35:33 +0200 Subject: [PATCH] Add M1 GPU Support not only CUDA Support by adding lines --- options/base_options.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/options/base_options.py b/options/base_options.py index 4ee0209d..9e3c3f16 100644 --- a/options/base_options.py +++ b/options/base_options.py @@ -80,8 +80,16 @@ def parse(self, save=True): self.opt.gpu_ids.append(id) # set gpu ids - if len(self.opt.gpu_ids) > 0: - torch.cuda.set_device(self.opt.gpu_ids[0]) + if not torch.backends.mps.is_available(): + if not torch.backends.mps.is_built(): + if len(self.opt.gpu_ids) > 0: + torch.cuda.set_device(self.opt.gpu_ids[0]) + else: + print("ERROR") + else: + print("ERROR") + else: + torch.device("mps") args = vars(self.opt)