Skip to content

Commit f2b03ca

Browse files
committed
add shell of CPU's version info
1 parent c7b5ac4 commit f2b03ca

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed

paddle/scripts/paddle_build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,7 @@ function main() {
14211421
init
14221422
if [ "$CMD" != "assert_file_approvals" ];then
14231423
python ${PADDLE_ROOT}/tools/summary_env.py
1424+
bash ${PADDLE_ROOT}/tools/get_cpu_info.sh
14241425
fi
14251426
case $CMD in
14261427
build_only)

tools/get_cpu_info.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/bash
2+
3+
if [ "`uname -s`" != "Linux" ]; then
4+
echo "Current scenario only support in Linux yet!"
5+
exit 0
6+
fi
7+
8+
echo "========================= Hardware Information ========================="
9+
sockets=`grep 'physical id' /proc/cpuinfo | sort -u | wc -l`
10+
cores_per_socket=`grep 'core id' /proc/cpuinfo | sort -u | wc -l`
11+
ht=`lscpu |grep "per core" |awk -F':' '{print $2}'|xargs`
12+
physical_cores=$((sockets * cores_per_socket))
13+
virtual_cores=`grep 'processor' /proc/cpuinfo | sort -u | wc -l`
14+
numa_nodes=`lscpu |grep "NUMA node(s)"|awk -F':' '{print $2}'|xargs`
15+
echo "CPU Name : `cat /proc/cpuinfo |grep -i "model name" |uniq |awk -F ':' '{print $2}'|xargs`"
16+
echo "CPU Family : `lscpu |grep \"CPU family\" |awk -F':' '{print $2}'|xargs`"
17+
echo "Socket Number : $sockets"
18+
echo "Cores Per Socket : $cores_per_socket"
19+
echo "Total Physical Cores : $physical_cores"
20+
echo "Total Virtual Cores : $virtual_cores"
21+
if [ $ht -eq 1 ]; then
22+
echo "Hyper Threading : OFF"
23+
if [ $physical_cores -ne $virtual_cores ]; then
24+
echo "Error: HT logical error"
25+
fi
26+
else
27+
echo "Hyper Threading : ON"
28+
if [ $physical_cores -ge $virtual_cores ]; then
29+
echo "Error: HT logical error"
30+
fi
31+
fi
32+
echo "NUMA Nodes : $numa_nodes"
33+
if [ $numa_nodes -lt $sockets ]; then
34+
echo "Warning: NUMA node is not enough for the best performance,\
35+
at least $sockets"
36+
fi
37+
38+
echo "-------------------------- Memory Information --------------------------"
39+
# dmidecode support start from 2.11
40+
dmi_ver=`dmidecode --version|awk -F '.' '{print $1}'|xargs`
41+
if [ $dmi_ver -lt 2 ]; then
42+
echo "Error: dmidecode unknown or version is too old"
43+
exit 0
44+
fi
45+
if [ `dmidecode | grep -ic "Permission denied"` -ne 0 ]; then
46+
echo "Error: need root to run dmidecode"
47+
exit 0
48+
fi
49+
max_dimms=0
50+
num_dimms_installed=0
51+
for dimm_id in `dmidecode |grep Locator|sort -u | awk -F ':' '{print $2}'`; do
52+
num_refered=`dmidecode |grep -wc "$dimm_id"`
53+
# the actual dimm id should be refered only once
54+
if [ $num_refered -eq 1 ]; then
55+
num_unknown=`dmidecode | awk '/'$dimm_id'/ {s=1; f=0};
56+
/Unknown/ {f=1};
57+
/Manufacturer/ {if (s==1) {print f; exit 0;}};'`
58+
if [ $num_unknown -eq 0 ]; then
59+
dimms_installed="$dimms_installed \n $dimm_id"
60+
((num_dimms_installed++))
61+
else
62+
dimms_uninstalled="$dimms_uninstalled \n $dimm_id"
63+
fi
64+
((max_dimms++))
65+
fi
66+
done
67+
echo "Installed DIMM number : $num_dimms_installed"
68+
num_dimms_mapped=`dmidecode | grep "Memory Device Mapped" | wc -l`
69+
if [ $num_dimms_installed -ne $num_dimms_mapped ]; then
70+
echo "Error: The installed DIMMs number does ont match the mapped memory device: $num_dimms_mapped"
71+
fi
72+
num_clock_configed=`dmidecode | grep -i "Configured Clock Speed" |grep -ic "Hz"`
73+
if [ $num_dimms_installed -ne $num_clock_configed ]; then
74+
echo "Error: The installed DIMMs number does ont match configured clocks: $num_clock_configed"
75+
fi
76+
echo -e "Installed DIMMs Locator: $dimms_installed"
77+
echo -e "Not installed DIMMs : $dimms_uninstalled"
78+
max_dimm_slots=`dmidecode | grep -c "Bank Locator"`
79+
echo "DIMMs max slots : $max_dimm_slots"
80+
if [ $max_dimms -ne $max_dimm_slots ]; then
81+
echo "Error: The max dimm slots do not match the max dimms: $max_dimms"
82+
fi
83+
free_ver_main=`free -V|awk -F ' ' '{print $NF}'|awk -F '.' '{print $1}'`
84+
free_ver_sub=`free -V|awk -F ' ' '{print $NF}'|awk -F '.' '{print $2}'`
85+
if [ $free_ver_main -lt 3 ] || [ $free_ver_sub -lt 3 ]; then
86+
mem_sz=`free |grep -i mem |awk -F' ' '{print $2}'|xargs`
87+
swap_sz=`free |grep -i swap |awk -F' ' '{print $2}'|xargs`
88+
total_sz=`free -t |grep -i total |tail -n 1| awk -F' ' '{print $2}'|xargs`
89+
mem_sz="`awk 'BEGIN{printf "%.1f\n",('$mem_sz'/1024/1024)}'` GB"
90+
swap_sz="`awk 'BEGIN{printf "%.1f\n",('$swap_sz'/1024/1024)}'` GB"
91+
total_sz="`awk 'BEGIN{printf "%.1f\n",('$total_sz'/1024/1024)}'` GB"
92+
else
93+
mem_sz=`free -h |grep -i mem |awk -F' ' '{print $2}'|xargs`
94+
swap_sz=`free -h |grep -i swap |awk -F' ' '{print $2}'|xargs`
95+
total_sz=`free -th |grep -i total |tail -n 1| awk -F' ' '{print $2}'|xargs`
96+
fi
97+
echo "Memory Size : $mem_sz"
98+
echo "Swap Memory Size : $swap_sz"
99+
echo "Total Memory Size : $total_sz"
100+
echo "Max Memory Capacity : `dmidecode |grep -i \"maximum capacity\"|sort -u|awk -F':' '{print $2}'|xargs`"
101+
# DIMMs fequency
102+
clock_speeds=`dmidecode | grep -i "Configured Clock Speed" | grep -i "Hz" |sort -u | awk -F':' '{print $2}'|xargs`
103+
echo "Configed Clock Speed : $clock_speeds"
104+
num_clock_type=`dmidecode | grep -i "Configured Clock Speed" | grep -i "Hz" |sort -u | wc -l`
105+
if [ $num_clock_type -ne 1 ]; then
106+
echo "Warning: Have more than 1 speed type, all DIMMs should have same fequency: $clock_speeds"
107+
fi
108+
109+
echo "========================= Software Information ========================="
110+
echo "BIOS Release Date : `dmidecode | grep "Release Date"|awk -F ':' '{print $2}'|xargs`"
111+
echo "OS Version : `cat /etc/redhat-release`"
112+
echo "Kernel Release Version : `uname -r`"
113+
echo "Kernel Patch Version : `uname -v`"
114+
echo "GCC Version :`gcc --version | head -n 1|awk -F '\\\(GCC\\\)' '{print $2}'`"
115+
if command -v cmake >/dev/null 2>&1; then
116+
cmake_ver=`cmake --version | head -n 1 | awk -F 'version' '{print $2}'`
117+
else
118+
cmake_ver=" Not installed"
119+
fi
120+
echo "CMake Version :$cmake_ver"
121+

0 commit comments

Comments
 (0)