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_gpu.sh 1.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. if [ $# -lt 2 ]
  17. then
  18. echo "Usage:\n \
  19. sh run_train.sh [DEVICE_NUM] [VISIABLE_DEVICES(0,1,2,3,4,5,6,7)]\n \
  20. "
  21. exit 1
  22. fi
  23. if [ $1 -lt 1 ] && [ $1 -gt 8 ]
  24. then
  25. echo "error: DEVICE_NUM=$1 is not in (1-8)"
  26. exit 1
  27. fi
  28. export DEVICE_NUM=$1
  29. export RANK_SIZE=$1
  30. BASEPATH=$(cd "`dirname $0`" || exit; pwd)
  31. export PYTHONPATH=${BASEPATH}:$PYTHONPATH
  32. if [ -d "../train" ];
  33. then
  34. rm -rf ../train
  35. fi
  36. mkdir ../train
  37. cd ../train || exit
  38. export CUDA_VISIBLE_DEVICES="$2"
  39. if [ $1 -gt 1 ]
  40. then
  41. mpirun -n $1 --allow-run-as-root \
  42. python3 ${BASEPATH}/../train.py > train.log 2>&1 &
  43. else
  44. python3 ${BASEPATH}/../train.py > train.log 2>&1 &
  45. fi