Skip to content

Commit 04bfed6

Browse files
authored
Merge pull request #7413 from tensor-tang/v1mac
enbale auto set env of V1 on Mac
2 parents 3ea2395 + 74c5e7c commit 04bfed6

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

paddle/scripts/submit_local.sh.in

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,18 @@ function cpu_config() {
4949
if [ "@WITH_MKL@" == "OFF" ]; then
5050
return 0
5151
fi
52-
ht=`lscpu |grep "per core"|awk -F':' '{print $2}'|xargs`
52+
platform="`uname -s`"
53+
ht=0
54+
if [ $platform == "Linux" ]; then
55+
ht=`lscpu |grep "per core"|awk -F':' '{print $2}'|xargs`
56+
elif [ $platform == "Darwin" ]; then
57+
if [`sysctl -n hw.physicalcpu` -eq `sysctl -n hw.logicalcpu`]; then
58+
# HT is OFF
59+
ht=1
60+
fi
61+
else
62+
return 0
63+
fi
5364
if [ $ht -eq 1 ]; then # HT is OFF
5465
if [ -z "$KMP_AFFINITY" ]; then
5566
export KMP_AFFINITY="granularity=fine,compact,0,0"
@@ -72,7 +83,15 @@ function threads_config() {
7283
# according to trainer_count and total processors
7384
# only when MKL enabled
7485
# auto set OPENBLAS_NUM_THREADS when do not use MKL
75-
processors=`grep "processor" /proc/cpuinfo|sort -u|wc -l`
86+
platform="`uname -s`"
87+
processors=0
88+
if [ $platform == "Linux" ]; then
89+
processors=`grep "processor" /proc/cpuinfo|sort -u|wc -l`
90+
elif [ $platform == "Darwin" ]; then
91+
processors=`sysctl -n hw.logicalcpu`
92+
else
93+
return 0
94+
fi
7695
trainers=`grep -Eo 'trainer_count.[0-9]+' <<< "$@" |grep -Eo '[0-9]+'|xargs`
7796
if [ -z $trainers ]; then
7897
trainers=1
@@ -148,11 +167,7 @@ else:
148167
sys.exit(0)
149168
EOF
150169

151-
if [ "`uname -s`" == "Linux" ]; then
152-
# only support on linux yet, with mac can use v2
153-
cpu_config
154-
fi
155-
170+
cpu_config
156171
# echo $KMP_AFFINITY $OMP_DYNAMIC
157172

158173
case "$1" in

0 commit comments

Comments
 (0)