mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-21 23:57:58 +01:00
Fix UI error caused by --idle-timeout
This commit is contained in:
parent
3aa646c1d0
commit
514fb2e451
@ -368,14 +368,16 @@ def clear_torch_cache():
|
||||
torch.cuda.empty_cache()
|
||||
|
||||
|
||||
def unload_model():
|
||||
def unload_model(keep_model_name=False):
|
||||
shared.model = shared.tokenizer = None
|
||||
shared.previous_model_name = shared.model_name
|
||||
shared.model_name = 'None'
|
||||
shared.lora_names = []
|
||||
shared.model_dirty_from_training = False
|
||||
clear_torch_cache()
|
||||
|
||||
if not keep_model_name:
|
||||
shared.model_name = 'None'
|
||||
|
||||
|
||||
def reload_model():
|
||||
unload_model()
|
||||
@ -393,7 +395,7 @@ def unload_model_if_idle():
|
||||
if time.time() - last_generation_time > shared.args.idle_timeout * 60:
|
||||
if shared.model is not None:
|
||||
logger.info("Unloading the model for inactivity.")
|
||||
unload_model()
|
||||
unload_model(keep_model_name=True)
|
||||
finally:
|
||||
shared.generation_lock.release()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user