提交 966a442e 编写于 作者: L Luo Tao

fix grep socket error in lscpu command

上级 ef3420e2
...@@ -83,11 +83,10 @@ def set_omp_mkl_env_vars(trainer_count): ...@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册