Tuchuanhuhuhu commited on
Commit
18731f2
·
1 Parent(s): 104cf1c

减少切换模型时的内存/显存占用

Browse files
Files changed (2) hide show
  1. modules/models.py +2 -1
  2. modules/presets.py +3 -0
modules/models.py CHANGED
@@ -391,6 +391,7 @@ class LLaMA_Client(BaseLLMModel):
391
 
392
  class ModelManager:
393
  def __init__(self, **kwargs) -> None:
 
394
  self.get_model(**kwargs)
395
 
396
  def get_model(
@@ -409,7 +410,7 @@ class ModelManager:
409
  dont_change_lora_selector = False
410
  if model_type != ModelType.OpenAI:
411
  config.local_embedding = True
412
- self.model = None
413
  model = None
414
  try:
415
  if model_type == ModelType.OpenAI:
 
391
 
392
  class ModelManager:
393
  def __init__(self, **kwargs) -> None:
394
+ self.model = None
395
  self.get_model(**kwargs)
396
 
397
  def get_model(
 
410
  dont_change_lora_selector = False
411
  if model_type != ModelType.OpenAI:
412
  config.local_embedding = True
413
+ del self.model
414
  model = None
415
  try:
416
  if model_type == ModelType.OpenAI:
modules/presets.py CHANGED
@@ -80,6 +80,9 @@ MODELS = [
80
  "llama-65b-hf",
81
  ] # 可选的模型
82
 
 
 
 
83
  for dir_name in os.listdir("models"):
84
  if os.path.isdir(os.path.join("models", dir_name)):
85
  if dir_name not in MODELS:
 
80
  "llama-65b-hf",
81
  ] # 可选的模型
82
 
83
+ os.makedirs("models", exist_ok=True)
84
+ os.makedirs("lora", exist_ok=True)
85
+ os.makedirs("history", exist_ok=True)
86
  for dir_name in os.listdir("models"):
87
  if os.path.isdir(os.path.join("models", dir_name)):
88
  if dir_name not in MODELS: