From 095a905d7203f2c15d752fa81fced9db28ea6c6d Mon Sep 17 00:00:00 2001 From: Bryce Date: Sun, 13 Nov 2022 14:25:52 -0800 Subject: [PATCH] fix: cpu generation doesn't use autocast autocast not supported on CPU https://github.com/pytorch/pytorch/issues/55374 https://github.com/invoke-ai/InvokeAI/pull/518 --- imaginairy/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imaginairy/utils.py b/imaginairy/utils.py index 2a321f4..3657558 100644 --- a/imaginairy/utils.py +++ b/imaginairy/utils.py @@ -68,7 +68,10 @@ def platform_appropriate_autocast(precision="autocast"): Allow calculations to run in mixed precision, which can be faster """ precision_scope = nullcontext - if precision == "autocast" and get_device() in ("cuda", "cpu"): + # autocast not supported on CPU + # https://github.com/pytorch/pytorch/issues/55374 + # https://github.com/invoke-ai/InvokeAI/pull/518 + if precision == "autocast" and get_device() in ("cuda",): precision_scope = autocast with precision_scope(get_device()): yield