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