Skip to content

Commit e670453

Browse files
committed
add script to check the cpu env
1 parent e0ac34a commit e670453

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

paddle/scripts/check_env.sh

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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 : `lscpu |grep \"name\" |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+
echo "DIMMs max slots : `dmidecode | grep "Bank Locator" | wc -l`"
40+
# dmidecode support start from 2.11
41+
num_dimms_installed=`dmidecode | grep "Memory Device Mapped" | wc -l`
42+
num_clock_configed=`dmidecode | grep -i "Configured Clock Speed" |grep -i "Hz" |wc -l`
43+
echo "Installed DIMM number : $num_dimms_installed"
44+
if [ $num_dimms_installed -ne $num_clock_configed ]; then
45+
echo "Error: installed DIMMs do ont match configured clocks: $num_clock_configed"
46+
fi
47+
echo "Memory Size : `free -h |grep -i mem |awk -F' ' '{print $2}'|xargs`"
48+
echo "Swap Memory Size : `free -h |grep -i swap |awk -F' ' '{print $2}'|xargs`"
49+
echo "Total Memory Size : `free -th |grep -i total |tail -n 1| awk -F' ' '{print $2}'|xargs`"
50+
echo "Max Memory Capacity : `dmidecode |grep -i \"maximum capacity\"|sort -u|awk -F':' '{print $2}'|xargs`"
51+
# DIMMs fequency
52+
clock_speeds=`dmidecode | grep -i "Configured Clock Speed" | grep -i "Hz" |sort -u | awk -F':' '{print $2}'|xargs`
53+
echo "Configed Clock Speed : $clock_speeds"
54+
num_clock_type=`dmidecode | grep -i "Configured Clock Speed" | grep -i "Hz" |sort -u | wc -l`
55+
if [ $num_clock_type -ne 1 ]; then
56+
echo "Warning: Have more than 1 speed type, all DIMMs should have same fequency: $clock_speeds"
57+
fi
58+
59+
echo "-------------------------- Turbo Information --------------------------"
60+
scaling_drive=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver`
61+
echo "Scaling Driver : $scaling_drive"
62+
if [ $scaling_drive == "intel_pstate" ] && [ -e /sys/devices/system/cpu/intel_pstate/no_turbo ]; then
63+
turbo=`cat /sys/devices/system/cpu/intel_pstate/no_turbo`
64+
if [ $turbo -eq 1 ]; then
65+
echo "Turbo Status : OFF"
66+
else
67+
echo "Turbo Status : ON"
68+
fi
69+
else
70+
echo "Warning: Scaling driver is not intel_pstarte, maybe should enable it in BIOS"
71+
echo "Turbo Status : Unknown"
72+
fi
73+
# cpu frequency
74+
num_max_freq=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq| sort -u |wc -l`
75+
num_min_freq=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_min_freq| sort -u |wc -l`
76+
if [ $num_max_freq -ne 1 ]; then
77+
echo "Error: the max_frequency of all CPU should be equal"
78+
fi
79+
if [ $num_min_freq -ne 1 ]; then
80+
echo "Error: the min_frequency of all CPU should be equal"
81+
fi
82+
max_freq=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq| uniq|xargs` # kHz
83+
max_freq=`awk 'BEGIN{printf "%.2f",('$max_freq' / 1000000)}'` # GHz
84+
min_freq=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_min_freq| uniq|xargs` # kHz
85+
min_freq=`awk 'BEGIN{printf "%.2f",('$min_freq' / 1000000)}'` # GHz
86+
echo "CPU Max Frequency : $max_freq GHz"
87+
echo "CPU Min Frequency : $min_freq GHz"
88+
# cpu governor
89+
num_governor=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor| sort -u |wc -l`
90+
if [ $num_governor -ne 1 ]; then
91+
echo "Error: the governor of all CPU should be the same"
92+
fi
93+
governor=`cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor| sort -u |uniq`
94+
echo "CPU Freq Governor : $governor"
95+
96+
97+
echo "========================= Software Information ========================="
98+
echo "BIOS Release Date : `dmidecode | grep "Release Date"|awk -F ':' '{print $2}'|xargs`"
99+
echo "OS Version : `cat /etc/redhat-release`"
100+
echo "Kernel Release Version : `uname -r`"
101+
echo "Kernel Patch Version : `uname -v`"
102+
echo "GCC Version :`gcc --version | head -n 1|awk -F '\\\(GCC\\\)' '{print $2}'`"
103+
echo "CMake Version :`cmake --version | head -n 1 | awk -F 'version' '{print $2}'`"
104+
echo "------------------ Environment Variables Information -------------------"
105+
kmp_affinity=`env | grep KMP_AFFINITY`
106+
omp_dynamic=`env | grep OMP_DYNAMIC`
107+
omp_nested=`env | grep OMP_NESTED`
108+
omp_num_threads=`env | grep OMP_NUM_THREADS`
109+
mkl_num_threads=`env | grep MKL_NUM_THREADS`
110+
mkl_dynamic=`env | grep MKL_DYNAMIC`
111+
if [ ! $kmp_affinity ]; then kmp_affinity="unset"; fi
112+
if [ ! $omp_dynamic ]; then omp_dynamic="unset"; fi
113+
if [ ! $omp_nested ]; then omp_nested="unset"; fi
114+
if [ ! $omp_num_threads ]; then omp_num_threads="unset"; fi
115+
if [ ! $mkl_num_threads ]; then mkl_num_threads="unset"; fi
116+
if [ ! $mkl_dynamic ]; then mkl_dynamic="unset"; fi
117+
echo "KMP_AFFINITY : $kmp_affinity"
118+
echo "OMP_DYNAMIC : $omp_dynamic"
119+
echo "OMP_NESTED : $omp_nested"
120+
echo "OMP_NUM_THREADS : $omp_num_threads"
121+
echo "MKL_NUM_THREADS : $mkl_num_threads"
122+
echo "MKL_DYNAMIC : $mkl_dynamic"
123+
# Check if any MKL related libraries have been installed in LD_LIBRARY_PATH
124+
for path in `echo $LD_LIBRARY_PATH | awk -F ':' '{for(i=1;i<=NF;++i)print $i}'`; do
125+
mkldnn_found=`find $path -name "libmkldnn.so"`
126+
if [ "$mkldnn_found" ]; then
127+
echo "Found MKL-DNN : $mkldnn_found"
128+
fi
129+
mklml_found=`find $path -name "libmklml_intel.so"`
130+
if [ "$mklml_found" ]; then
131+
echo "Found MKLML : $mklml_found"
132+
fi
133+
iomp_found=`find $path -name "libiomp5.so"`
134+
if [ "$iomp_found" ]; then
135+
echo "Found IOMP : $iomp_found"
136+
fi
137+
done
138+
139+
# dump all details for fully check
140+
lscpu > lscpu.dump
141+
dmidecode > dmidecode.dump

0 commit comments

Comments
 (0)