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_train.sh 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env 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. run_ascend()
  17. {
  18. if [ $2 -lt 1 ] && [ $2 -gt 8 ]
  19. then
  20. echo "error: DEVICE_NUM=$2 is not in (1-8)"
  21. exit 1
  22. fi
  23. if [ ! -d $5 ] && [ ! -f $5 ]
  24. then
  25. echo "error: DATASET_PATH=$5 is not a directory or file"
  26. exit 1
  27. fi
  28. BASEPATH=$(cd "`dirname $0`" || exit; pwd)
  29. export PYTHONPATH=${BASEPATH}:$PYTHONPATH
  30. if [ -d "../train" ];
  31. then
  32. rm -rf ../train
  33. fi
  34. mkdir ../train
  35. cd ../train || exit
  36. python ${BASEPATH}/../src/launch.py \
  37. --nproc_per_node=$2 \
  38. --visible_devices=$4 \
  39. --server_id=$3 \
  40. --training_script=${BASEPATH}/../train.py \
  41. --dataset_path=$5 \
  42. --pre_trained=$6 \
  43. --device_target=$1 &> train.log & # dataset train folder
  44. }
  45. if [ $# -gt 6 ] || [ $# -lt 4 ]
  46. then
  47. echo "Usage:\n \
  48. Ascend: sh run_train.sh Ascend [DEVICE_NUM] [SERVER_IP(x.x.x.x)] [VISIABLE_DEVICES(0,1,2,3,4,5,6,7)] [DATASET_PATH] [CKPT_PATH]\n \
  49. "
  50. exit 1
  51. fi
  52. if [ $1 = "Ascend" ] ; then
  53. run_ascend "$@"
  54. else
  55. echo "not support platform"
  56. fi;