File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 1010from dataclasses import dataclass
1111from typing import TYPE_CHECKING
1212
13+ import psutil
1314import regex as re
1415import torch
1516
@@ -147,11 +148,21 @@ def get_device_total_memory(cls, device_id: int = 0) -> int:
147148 from vllm .utils .mem_constants import GiB_bytes
148149
149150 kv_cache_space = envs .VLLM_CPU_KVCACHE_SPACE
151+ node_dir = "/sys/devices/system/node"
150152 if kv_cache_space is None :
151- kv_cache_space = 4 * GiB_bytes # type: ignore
153+ nodes = (
154+ [d for d in os .listdir (node_dir ) if d .startswith ("node" )]
155+ if os .path .exists (node_dir )
156+ else []
157+ )
158+ num_numa_nodes = len (nodes ) or 1
159+ free_cpu_memory = psutil .virtual_memory ().total // num_numa_nodes
160+ DEFAULT_CPU_MEM_UTILIZATION = 0.5
161+ kv_cache_space = int (free_cpu_memory * DEFAULT_CPU_MEM_UTILIZATION )
162+ kv_cache_space_gib = kv_cache_space / GiB_bytes
152163 logger .warning_once (
153- "Environment variable VLLM_CPU_KVCACHE_SPACE (GiB) "
154- "for CPU backend is not set, using 4 by default ."
164+ "VLLM_CPU_KVCACHE_SPACE not set. Using "
165+ f" { kv_cache_space_gib :.2f } GiB for KV cache ."
155166 )
156167 else :
157168 kv_cache_space *= GiB_bytes
You can’t perform that action at this time.
0 commit comments