Skip to content

Commit 7c48c31

Browse files
committed
update readme
1 parent 2aa5b63 commit 7c48c31

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,24 @@
22

33
## Overview
44

5-
When comfyui run in container, if the container is set with a memory limit, psutil cannot correctly read the available memory and maximum memory. It only reads the memory size of the host machine, which will cause some tasks to oom. This extension detects when comfyui is running in a container, reads the memory limit of the container, and uses the monkey patch method to replace some values ​​returned by `psutil.virtual_memory`, such as `total` `used` `available` `percent`.
5+
This extension is designed to address the issue where ComfyUI, when running in a memory-limited container, fails to correctly detect the available memory size.
6+
7+
ComfyUI and some of its nodes use the `psutil` library. Due to historical reasons, the `psutil.virtual_memory` function cannot accurately read the container's available and maximum memory limits—it instead retrieves the host machine's memory statistics. This discrepancy can lead to OOM (Out of Memory) errors in certain tasks.
8+
9+
## Solution
10+
This extension detects whether ComfyUI is running inside a container, reads the container's memory limits, and applies a Monkey Patch to override specific return values of `psutil.virtual_memory`. Currently, it modifies the following memory metrics:
11+
- **Total memory (`total`)**
12+
- **Used memory (`used`)**
13+
- **Available memory (`available`)**
14+
- **Memory usage percentage (`percent`)**
15+
16+
By doing so, the memory statistics correctly reflect the container's actual limits rather than the host machine's resources.
17+
18+
## Benefits
19+
With this extension:
20+
- ComfyUI and its nodes can make informed decisions based on accurate memory constraints.
21+
- OOM (Out of Memory) errors are effectively prevented in containerized environments.
22+
- Memory-related nodes (such as **crytools' Statistic Node**) now display correct usage information.
623

724
``` bash
825
# Run ComfyUI in container with 10GB memory limit

0 commit comments

Comments
 (0)