mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-13 15:02:37 +08:00
Try to disable pinned memory if wrong behavior detected.
Not sure if this is going to improve anything
This commit is contained in:
parent
c350009236
commit
aa0a025df9
@ -1128,6 +1128,16 @@ def pin_memory(tensor):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def disable_pinned():
|
||||||
|
global MAX_PINNED_MEMORY
|
||||||
|
global TOTAL_PINNED_MEMORY
|
||||||
|
MAX_PINNED_MEMORY = -1
|
||||||
|
logging.warning("Bad behavior detected, disabling pinned memory")
|
||||||
|
for ptr in PINNED_MEMORY: # TODO: check if this makes things worse
|
||||||
|
torch.cuda.cudart().cudaHostUnregister(ptr)
|
||||||
|
PINNED_MEMORY.clear()
|
||||||
|
TOTAL_PINNED_MEMORY = 0
|
||||||
|
|
||||||
def unpin_memory(tensor):
|
def unpin_memory(tensor):
|
||||||
global TOTAL_PINNED_MEMORY
|
global TOTAL_PINNED_MEMORY
|
||||||
if MAX_PINNED_MEMORY <= 0:
|
if MAX_PINNED_MEMORY <= 0:
|
||||||
@ -1142,6 +1152,7 @@ def unpin_memory(tensor):
|
|||||||
size_stored = PINNED_MEMORY.get(ptr, None)
|
size_stored = PINNED_MEMORY.get(ptr, None)
|
||||||
if size_stored is None:
|
if size_stored is None:
|
||||||
logging.warning("Tried to unpin tensor not pinned by ComfyUI")
|
logging.warning("Tried to unpin tensor not pinned by ComfyUI")
|
||||||
|
disable_pinned()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if size != size_stored:
|
if size != size_stored:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user