You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

run_distribute_train.sh 1.6 kB

5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. # Copyright 2020 Huawei Technologies Co., Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # ============================================================================
  16. DATA_DIR=$2
  17. export RANK_TABLE_FILE=$1
  18. export RANK_SIZE=8
  19. PATH_CHECKPOINT=""
  20. if [ $# == 3 ]
  21. then
  22. PATH_CHECKPOINT=$3
  23. fi
  24. cores=`cat /proc/cpuinfo|grep "processor" |wc -l`
  25. echo "the number of logical core" $cores
  26. avg_core_per_rank=`expr $cores \/ $RANK_SIZE`
  27. core_gap=`expr $avg_core_per_rank \- 1`
  28. echo "avg_core_per_rank" $avg_core_per_rank
  29. echo "core_gap" $core_gap
  30. for((i=0;i<RANK_SIZE;i++))
  31. do
  32. start=`expr $i \* $avg_core_per_rank`
  33. export DEVICE_ID=$i
  34. export RANK_ID=$i
  35. export DEPLOY_MODE=0
  36. export GE_USE_STATIC_MEMORY=1
  37. end=`expr $start \+ $core_gap`
  38. cmdopt=$start"-"$end
  39. rm -rf LOG$i
  40. mkdir ./LOG$i
  41. cp *.py ./LOG$i
  42. cd ./LOG$i || exit
  43. echo "start training for rank $i, device $DEVICE_ID"
  44. env > env.log
  45. taskset -c $cmdopt python ../train.py \
  46. --is_distribute=1 \
  47. --device_id=$DEVICE_ID \
  48. --pretrained=$PATH_CHECKPOINT \
  49. --data_dir=$DATA_DIR > log.txt 2>&1 &
  50. cd ../
  51. done