From c79fce182ca27021ac744d77eea5950e8c9aa34d Mon Sep 17 00:00:00 2001 From: db <962888866@qq.com> Date: Wed, 26 Apr 2023 21:27:28 +0800 Subject: [PATCH] support for macOS. --- modules/shared.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/shared.py b/modules/shared.py index 6f362a7ca..b234d2d2a 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -320,12 +320,23 @@ options_templates.update(options_section(('saving-paths', "Image Paths"), { "outdir_save": OptionInfo("outputs/save", "Directory for saving images using the Save button", component_args=hide_dirs), })) +cuda_dtype = OptionInfo("FP16", "Device precision type", gr.Radio, lambda: {"choices": ["FP32", "FP16", "BF16"]}) +no_half = OptionInfo(False, "Use full precision for model (--no-half)") +no_half_vae = OptionInfo(False, "Use full precision for VAE (--no-half-vae)") +upcast_sampling = OptionInfo(False, + "Enable upcast sampling. Usually produces similar results to --no-half with better performance while using less memory") +# support for macOS. +if sys.platform == "darwin": + cuda_dtype.default = "FP32" + upcast_sampling.default = True + + options_templates.update(options_section(('cuda', "CUDA Settings"), { "precision": OptionInfo("Autocast", "Precision type", gr.Radio, lambda: {"choices": ["Autocast", "Full"]}), - "cuda_dtype": OptionInfo("FP16", "Device precision type", gr.Radio, lambda: {"choices": ["FP32", "FP16", "BF16"]}), - "no_half": OptionInfo(False, "Use full precision for model (--no-half)"), - "no_half_vae": OptionInfo(False, "Use full precision for VAE (--no-half-vae)"), - "upcast_sampling": OptionInfo(False, "Enable upcast sampling. Usually produces similar results to --no-half with better performance while using less memory"), + "cuda_dtype": cuda_dtype, + "no_half": no_half, + "no_half_vae": no_half_vae, + "upcast_sampling": upcast_sampling, "disable_nan_check": OptionInfo(True, "Do not check if produced images/latent spaces have NaN values"), "rollback_vae": OptionInfo(False, "Attempt to roll back VAE when produced NaN values, requires NaN check (experimental)"), "opt_channelslast": OptionInfo(False, "Use channels last as torch memory format "),