From f4a19af04f134669da298ce9ecb61bcd01107a0d Mon Sep 17 00:00:00 2001 From: gabrielrotbart Date: Fri, 2 Sep 2022 14:55:24 +0300 Subject: [PATCH 1/2] fix scope being set to autocast even for m1 --- ldm/simplet2i.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index 49a9fd38c8..b46ecbae43 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -280,7 +280,10 @@ class T2I: ), 'can only work with strength in [0.0, 1.0]' width, height, _ = self._resolution_check(width, height, log=True) - scope = autocast if self.precision == 'autocast' else nullcontext + if self.precision == 'autocast' and torch.cuda.is_available(): + scope = autocast + else: + scope = nullcontext if sampler_name and (sampler_name != self.sampler_name): self.sampler_name = sampler_name From 0b582a40d0b017220edd3b5610e47f9139609376 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 2 Sep 2022 10:17:51 -0400 Subject: [PATCH 2/2] add developer's guidance for refactoring this change --- ldm/simplet2i.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index b46ecbae43..10720a7483 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -280,6 +280,10 @@ class T2I: ), 'can only work with strength in [0.0, 1.0]' width, height, _ = self._resolution_check(width, height, log=True) + + # TODO: - Check if this is still necessary to run on M1 devices. + # - Move code into ldm.dream.devices to live alongside other + # special-hardware casing code. if self.precision == 'autocast' and torch.cuda.is_available(): scope = autocast else: