Skip to content

Commit 1e6f85e

Browse files
authored
Merge pull request #5952 from luotao1/fix_lscpu_log
fix grep socket error in lscpu command
2 parents 217c6a3 + 966a442 commit 1e6f85e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

python/paddle/v2/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,10 @@ def num_physical_cores():
8383
'''Get the number of physical cores'''
8484
if platform.system() == "Linux":
8585
num_sockets = int(
86-
os.popen("lscpu |grep \"Socket\" |awk -F':' '{print $2}'|xargs")
86+
os.popen("grep 'physical id' /proc/cpuinfo | sort -u | wc -l")
8787
.read())
8888
num_cores_per_socket = int(
89-
os.popen(
90-
"lscpu |grep \"per socket\" |awk -F':' '{print $2}'|xargs")
89+
os.popen("grep 'core id' /proc/cpuinfo | sort -u | wc -l")
9190
.read())
9291
return num_sockets * num_cores_per_socket
9392
else:

0 commit comments

Comments
 (0)