pinned-memory-related issue #15527
|
Sometime ago I wrote an inquiry into smart memory causing OOM when using video models like wan and, recently, minimax H3 (#14462). After months' experiment, I did many things including expanding virtual RAM on disk, etc. And smart memory and dynamic vram both works fine. Yet the problems persist from time to time. I finally disabled pinned-memory and video-related workflows work smoothly without error since then. I read that pinned-memory is about locking a part in RAM and allow faster RAM-VRAM exchaange. What might be the reason behind this potential bug and what can I do if I really want this acceleration? |
Replies: 1 comment 3 replies
|
Pinned memory is not a general "more speed, no downside" switch. For the video workflows you mention, disabling it being more stable is a useful signal. In ComfyUI's current code, pinned memory is used as a host-side buffer for model/offload transfers. The So the likely reason is system-RAM pressure, not only VRAM pressure. Pinned host memory is RAM that the OS/GPU driver cannot freely page/move. On huge video models, you can end up with this pattern:
That also explains why expanding virtual RAM did not fully fix it: pagefile helps normal pageable memory, but it does not make pinned host pages cheap. For big Wan / MiniMax-style video runs, stability can be better with pinned memory off because the OS has more freedom to manage RAM. If you want to test whether the acceleration is worth keeping, I would do it as an A/B test on the same workflow:
In short: yes, pinned memory can speed transfers, but on memory-edge video workflows it can make RAM pressure worse. If disabling it makes Wan/MiniMax runs smooth, that is a valid production setting rather than a workaround you must undo. If this matches your tests, please mark it as answered so other video-workflow OOM cases can find the pinned-memory tradeoff. |
Pinned memory is not a general "more speed, no downside" switch. For the video workflows you mention, disabling it being more stable is a useful signal.
In ComfyUI's current code, pinned memory is used as a host-side buffer for model/offload transfers. The
pin_memory()path allocates host buffer space, asks the memory manager for pin budget/registerable size, releases extra RAM headroom first, and then calls CUDA host registration (cudaHostRegister). If those checks fail, it tries to reuse/steal an existing pin instead of making an unlimited new one. The CLI flag--disable-pinned-memorybypasses that path.So the likely reason is system-RAM pressure, not only VRAM pressure. Pinned host me…