From 53573fa073b5ba670649c5d9066774b01b76b98a Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Tue, 10 Oct 2023 02:36:19 -0700 Subject: [PATCH] fix auto_cast (#622) --- fooocus_version.py | 2 +- modules/patch.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fooocus_version.py b/fooocus_version.py index 78de3d02..aabdefe9 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '2.1.36' +version = '2.1.37' diff --git a/modules/patch.py b/modules/patch.py index b10eaf8b..d0cca47d 100644 --- a/modules/patch.py +++ b/modules/patch.py @@ -455,7 +455,20 @@ def text_encoder_device_patched(): return comfy.model_management.get_torch_device() +def patched_get_autocast_device(dev): + # https://github.com/lllyasviel/Fooocus/discussions/571 + # https://github.com/lllyasviel/Fooocus/issues/620 + result = '' + if hasattr(dev, 'type'): + result = str(dev.type) + if 'cuda' in result: + return 'cuda' + else: + return 'cpu' + + def patch_all(): + comfy.model_management.get_autocast_device = patched_get_autocast_device comfy.samplers.SAMPLER_NAMES += ['dpmpp_fooocus_2m_sde_inpaint_seamless'] comfy.model_management.text_encoder_device = text_encoder_device_patched comfy.model_patcher.ModelPatcher.calculate_weight = calculate_weight_patched