mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-23 21:10:49 +08:00
Implement unload_text_encoder for memory cleanup
Add unload_text_encoder function to manage encoder memory.
This commit is contained in:
parent
387aeed9ce
commit
63419c107b
@ -1550,6 +1550,7 @@ def unload_all_models_full():
|
|||||||
logging.info("All models unloaded successfully (manual full unload).")
|
logging.info("All models unloaded successfully (manual full unload).")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(f"Model unload warning: {e}")
|
logging.warning(f"Model unload warning: {e}")
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
@ -1559,4 +1560,14 @@ def cleanup_ram():
|
|||||||
torch.cuda.empty_cache()
|
torch.cuda.empty_cache()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
def unload_text_encoder(encoder):
|
||||||
|
if encoder is None:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
if hasattr(encoder, "model"):
|
||||||
|
del encoder.model
|
||||||
|
del encoder
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
cleanup_ram()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user