diff --git a/TODO.md b/TODO.md index 45629f545..beda77275 100644 --- a/TODO.md +++ b/TODO.md @@ -6,12 +6,16 @@ Stuff to be fixed... - Fix extensions imports - ClipSkip not updated on read gen info +- Usage of `sd_vae` in quick settings +- Run VAE with hires at 1280 + ## Features Stuff to be added... - Add Gradio base themes: +- Add gradio theme maker - Create new GitHub hooks/actions for CI/CD - Move Restart Server from WebUI to Launch and reload modules - Redo Extensions tab: see diff --git a/modules/devices.py b/modules/devices.py index 47b210f46..ada40cb63 100644 --- a/modules/devices.py +++ b/modules/devices.py @@ -54,17 +54,17 @@ def torch_gc(): def set_cuda_params(): - if not torch.cuda.is_available(): - return from modules import shared - if torch.backends.cudnn.is_available(): - torch.backends.cudnn.benchmark = shared.opts.cudnn_benchmark - torch.backends.cudnn.benchmark_limit = 0 - torch.backends.cudnn.allow_tf32 = shared.opts.cuda_allow_tf32 - torch.backends.cuda.matmul.allow_tf32 = shared.opts.cuda_allow_tf32 - torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = shared.opts.cuda_allow_tf16_reduced - torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = shared.opts.cuda_allow_tf16_reduced + if torch.cuda.is_available(): + torch.backends.cuda.matmul.allow_tf32 = shared.opts.cuda_allow_tf32 + torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = shared.opts.cuda_allow_tf16_reduced + torch.backends.cuda.matmul.allow_bf16_reduced_precision_reduction = shared.opts.cuda_allow_tf16_reduced + if torch.backends.cudnn.is_available(): + torch.backends.cudnn.benchmark = shared.opts.cudnn_benchmark + torch.backends.cudnn.benchmark_limit = 0 + torch.backends.cudnn.allow_tf32 = shared.opts.cuda_allow_tf32 global dtype, dtype_vae, dtype_unet, unet_needs_upcast # pylint: disable=global-statement + # set dtype if shared.opts.cuda_dtype == 'FP16': dtype = torch.float16 dtype_vae = torch.float16 @@ -73,10 +73,12 @@ def set_cuda_params(): dtype = torch.bfloat16 dtype_vae = torch.bfloat16 dtype_unet = torch.bfloat16 - if shared.opts.cuda_dtype == 'FP32': + if shared.opts.cuda_dtype == 'FP32' or shared.opts.no_half: dtype = torch.float32 dtype_vae = torch.float32 dtype_unet = torch.float32 + if shared.opts.no_half_vae: # set dtype again as no-half-vae options take priority + dtype_vae = torch.float32 unet_needs_upcast = shared.opts.upcast_sampling diff --git a/modules/sd_models.py b/modules/sd_models.py index c46f91dd2..362fad078 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -403,7 +403,6 @@ def load_model(checkpoint_info=None, already_loaded_state_dict=None): current_checkpoint_info = shared.sd_model.sd_checkpoint_info sd_hijack.model_hijack.undo_hijack(shared.sd_model) shared.sd_model = None - gc.collect() devices.torch_gc() @@ -526,9 +525,7 @@ def reload_model_weights(sd_model=None, info=None): def unload_model_weights(sd_model=None, _info=None): from modules import sd_hijack timer = Timer() - if shared.sd_model: - # shared.sd_model.cond_stage_model.to(devices.cpu) # shared.sd_model.first_stage_model.to(devices.cpu) shared.sd_model.to(devices.cpu) @@ -538,9 +535,7 @@ def unload_model_weights(sd_model=None, _info=None): gc.collect() devices.torch_gc() torch.cuda.empty_cache() - print(f"Unloaded weights {timer.summary()}") - return sd_model diff --git a/modules/textual_inversion/textual_inversion.py b/modules/textual_inversion/textual_inversion.py index 6979e68d7..9bcf205ab 100644 --- a/modules/textual_inversion/textual_inversion.py +++ b/modules/textual_inversion/textual_inversion.py @@ -130,6 +130,9 @@ class EmbeddingDatabase: return embedding def get_expected_shape(self): + if shared.sd_model is None: + print('Model not loaded') + return 0 vec = shared.sd_model.cond_stage_model.encode_embedding_init_text(",", 1) return vec.shape[1]