fix grep socket error in lscpu command

release/0.11.0
Luo Tao 8 years ago
parent ef3420e2b9
commit 966a442eb0

@ -83,11 +83,10 @@ def set_omp_mkl_env_vars(trainer_count):
'''Get the number of physical cores''' '''Get the number of physical cores'''
if platform.system() == "Linux": if platform.system() == "Linux":
num_sockets = int( num_sockets = int(
os.popen("lscpu |grep \"Socket\" |awk -F':' '{print $2}'|xargs") os.popen("grep 'physical id' /proc/cpuinfo | sort -u | wc -l")
.read()) .read())
num_cores_per_socket = int( num_cores_per_socket = int(
os.popen( os.popen("grep 'core id' /proc/cpuinfo | sort -u | wc -l")
"lscpu |grep \"per socket\" |awk -F':' '{print $2}'|xargs")
.read()) .read())
return num_sockets * num_cores_per_socket return num_sockets * num_cores_per_socket
else: else:

Loading…
Cancel
Save