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_optimizer_parallel.sh 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. set -e
  17. BASE_PATH=$(cd "$(dirname $0)"; pwd)
  18. CONFIG_PATH=/home/workspace/mindspore_config
  19. export DEVICE_NUM=4
  20. export RANK_SIZE=$DEVICE_NUM
  21. source ${BASE_PATH}/env.sh
  22. unset SLOG_PRINT_TO_STDOUT
  23. export MINDSPORE_HCCL_CONFIG_PATH=$CONFIG_PATH/hccl/rank_tabel_4p/rank_table_${DEVICE_NUM}p_1.json
  24. export LD_LIBRARY_PATH=/usr/local/Ascend/opp/op_impl/built-in/ai_core/tbe/op_tiling:${LD_LIBRARY_PATH}
  25. export ASCEND_OPP_PATH=/usr/local/Ascend/opp/
  26. process_pid=()
  27. for((i=0; i<$DEVICE_NUM; i++)); do
  28. rm -rf ${BASE_PATH}/optimizer_parallel${i}
  29. mkdir ${BASE_PATH}/optimizer_parallel${i}
  30. cp -r ${BASE_PATH}/optimizer_parallel.py ${BASE_PATH}/optimizer_parallel${i}/
  31. cd ${BASE_PATH}/optimizer_parallel${i}
  32. export RANK_ID=${i}
  33. export DEVICE_ID=${i}
  34. echo "start training for device $i"
  35. env > env$i.log
  36. pytest -s -v optimizer_parallel.py::test_optimizer_parallel_auto_4p_6_parameter_same_strategy_1_1_2_1_momentum > optimizer_parallel$i.log 2>&1 &
  37. process_pid[${i}]=`echo $!`
  38. done
  39. for((i=0; i<${DEVICE_NUM}; i++)); do
  40. wait ${process_pid[i]}
  41. status=`echo $?`
  42. if [ "${status}" != "0" ]; then
  43. echo "[ERROR] test_optimizer_parallel failed. status: ${status}"
  44. exit 1
  45. else
  46. echo "[INFO] test_optimizer_parallel success."
  47. fi
  48. done
  49. exit 0