1#!/bin/bash 2# Copyright 2024 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=2 20export RANK_SIZE=$DEVICE_NUM 21unset SLOG_PRINT_TO_STDOUT 22export MINDSPORE_HCCL_CONFIG_PATH=$CONFIG_PATH/hccl/rank_table_${DEVICE_NUM}p.json 23 24process_pid=() 25for((i=0; i<$DEVICE_NUM; i++)); do 26 rm -rf ${BASE_PATH}/test_came${i} 27 mkdir ${BASE_PATH}/test_came${i} 28 cp -r ${BASE_PATH}/came_optimizer_shard.py ${BASE_PATH}/came.py ${BASE_PATH}/test_came${i}/ 29 cd ${BASE_PATH}/test_came${i} 30 export RANK_ID=${i} 31 export DEVICE_ID=${i} 32 33 pytest -vra --disable-warnings came_optimizer_shard.py::came_parallel > test_came_$i.log 2>&1 & 34 process_pid[${i}]=`echo $!` 35done 36 37for((i=0; i<${DEVICE_NUM}; i++)); do 38 wait ${process_pid[i]} 39 status=`echo $?` 40 if [ "${status}" != "0" ]; then 41 echo "[ERROR] test_came failed. status: ${status}" 42 exit 1 43 else 44 echo "[INFO] test_came success." 45 fi 46done 47 48exit 0 49