Make VRAM_Debug report the values within the node itself

This commit is contained in:
kijai 2024-05-04 10:09:17 +03:00
parent 11a62b6fc3
commit a8c216c7e9
2 changed files with 25 additions and 5 deletions

View File

@ -558,9 +558,9 @@ and performs comfy model management functions and garbage collection,
reports free VRAM before and after the operations.
"""
def VRAMdebug(self, gc_collect,empty_cache, unload_all_models, image_pass=None, model_pass=None, any_input=None):
def VRAMdebug(self, gc_collect, empty_cache, unload_all_models, image_pass=None, model_pass=None, any_input=None):
freemem_before = model_management.get_free_memory()
print("VRAMdebug: free memory before: ", freemem_before)
print("VRAMdebug: free memory before: ", f"{freemem_before:,.0f}")
if empty_cache:
model_management.soft_empty_cache()
if unload_all_models:
@ -569,9 +569,12 @@ reports free VRAM before and after the operations.
import gc
gc.collect()
freemem_after = model_management.get_free_memory()
print("VRAMdebug: free memory after: ", freemem_after)
print("VRAMdebug: freed memory: ", freemem_after - freemem_before)
return (any_input, image_pass, model_pass, freemem_before, freemem_after)
print("VRAMdebug: free memory after: ", f"{freemem_after:,.0f}")
print("VRAMdebug: freed memory: ", f"{freemem_after - freemem_before:,.0f}")
return {"ui": {
"text": [f"{freemem_before:,.0f}x{freemem_after:,.0f}"]},
"result": (any_input, image_pass, model_pass, freemem_before, freemem_after)
}
class SomethingToString:
@classmethod

View File

@ -113,6 +113,23 @@ app.registerExtension({
return r
}
break;
case "VRAM_Debug":
const onVRAM_DebugConnectInput = nodeType.prototype.onConnectInput;
nodeType.prototype.onConnectInput = function (targetSlot, type, output, originNode, originSlot) {
const v = onVRAM_DebugConnectInput?.(this, arguments);
targetSlot.outputs[3]["name"] = "freemem_before"
targetSlot.outputs[4]["name"] = "freemem_after"
return v;
}
const onVRAM_DebugExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function(message) {
const r = onVRAM_DebugExecuted? onVRAM_DebugExecuted.apply(this,arguments): undefined
let values = message["text"].toString().split('x');
this.outputs[3]["name"] = values[0] + " freemem_before"
this.outputs[4]["name"] = values[1] + " freemem_after"
return r
}
break;
case "JoinStringMulti":
nodeType.prototype.onNodeCreated = function () {