[CPU] fix OOM when mem-fraction is not set (#9090)

This commit is contained in:
Zaili Wang
2025-09-11 14:52:22 +08:00
committed by GitHub
parent 4aa1e69bc7
commit ef959d7b85
6 changed files with 29 additions and 16 deletions

View File

@@ -434,7 +434,9 @@ def get_available_gpu_memory(
elif device == "cpu":
# TODO: rename the variables in the current function to be not GPU specific
free_gpu_memory = psutil.virtual_memory().available
total_free_memory = psutil.virtual_memory().available
n_numa_node: int = len(get_cpu_ids_by_node())
free_gpu_memory = round(total_free_memory / n_numa_node, 3)
elif device == "npu":
num_gpus = torch.npu.device_count()
assert gpu_id < num_gpus