[CPU] misc updates (#11906)
This commit is contained in:
@@ -1623,13 +1623,18 @@ def get_cpu_memory_capacity():
|
||||
for numa_id in range(n_numa_node):
|
||||
file_meminfo = f"node{numa_id}/meminfo"
|
||||
with open(os.path.join(file_prefix, file_meminfo), "r") as f:
|
||||
# 1st line contains 'MemTotal'
|
||||
line = f.read().split("\n")[0]
|
||||
numa_mem_list.append(int(line.split()[3]))
|
||||
# MemTotal info is at the 1st line
|
||||
line = f.readline()
|
||||
# Expected format: "Node 0 MemTotal: 100000000 kB"
|
||||
parts = line.split()
|
||||
if len(parts) >= 4 and parts[2] == "MemTotal:":
|
||||
numa_mem_list.append(int(parts[3]))
|
||||
else:
|
||||
raise ValueError(f"Unexpected format in {file_meminfo}: {line}")
|
||||
# Retrieved value in KB, need MB
|
||||
numa_mem = float(min(numa_mem_list) // 1024)
|
||||
return numa_mem
|
||||
except FileNotFoundError:
|
||||
except (FileNotFoundError, ValueError, IndexError):
|
||||
numa_mem = psutil.virtual_memory().total / n_numa_node
|
||||
# Retrieved value in Byte, need MB
|
||||
return float(numa_mem // (1 << 20))
|
||||
|
||||
Reference in New Issue
Block a user