vllm.utils.cpu_resource_utils ¶
Functions:
-
check_cgroup_memory_available–Log cgroup memory headroom for an upcoming allocation.
-
get_cgroup_memory_limit–Return the cgroup memory limit in bytes, or None.
-
get_cgroup_memory_usage–Return the current cgroup memory usage in bytes, or None.
-
parse_id_list–Parses strings like '0-2,4,7-8' into [0, 1, 2, 4, 7, 8].
_synthesize_cpu_list() cached ¶
Synthesize a flat CPU list: each logical CPU is its own core on NUMA node 0. Used when lscpu output is unavailable or unparsable (e.g. macOS, RISC-V).
Source code in vllm/utils/cpu_resource_utils.py
check_cgroup_memory_available(required_bytes, allocation_name) ¶
Log cgroup memory headroom for an upcoming allocation.
Parameters:
-
(required_bytes¶int) –Bytes required by the allocation.
-
(allocation_name¶str) –Human-readable name used in log messages.
Low headroom logs a warning, but does not reject the allocation because cgroup usage can include reclaimable memory. If the cgroup limit or usage cannot be read, the check is skipped.
Source code in vllm/utils/cpu_resource_utils.py
get_cgroup_memory_limit() cached ¶
Return the cgroup memory limit in bytes, or None.
Supports both cgroup v2 (unified) and v1. Returns None when not running under a constrained cgroup (e.g. bare metal, or limit reported as max/an unrealistically large value).
Source code in vllm/utils/cpu_resource_utils.py
get_cgroup_memory_usage() ¶
Return the current cgroup memory usage in bytes, or None.
The usage value is intentionally read on every call because cgroup memory usage changes while the process is running.
Source code in vllm/utils/cpu_resource_utils.py
parse_id_list(raw_str) ¶
Parses strings like '0-2,4,7-8' into [0, 1, 2, 4, 7, 8].