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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 [ $# != 4 ]
  17. then
  18. echo "Usage: sh run_eval.sh [resnet50|resnet101] [cifar10|imagenet2012] [DATASET_PATH] [CHECKPOINT_PATH]"
  19. exit 1
  20. fi
  21. if [ $1 != "resnet50" ] && [ $1 != "resnet101" ]
  22. then
  23. echo "error: the selected net is neither resnet50 nor resnet101"
  24. exit 1
  25. fi
  26. if [ $2 != "cifar10" ] && [ $2 != "imagenet2012" ]
  27. then
  28. echo "error: the selected dataset is neither cifar10 nor imagenet2012"
  29. exit 1
  30. fi
  31. if [ $1 == "resnet101" ] && [ $2 == "cifar10" ]
  32. then
  33. echo "error: evaluating resnet101 with cifar10 dataset is unsupported now!"
  34. exit 1
  35. fi
  36. get_real_path(){
  37. if [ "${1:0:1}" == "/" ]; then
  38. echo "$1"
  39. else
  40. echo "$(realpath -m $PWD/$1)"
  41. fi
  42. }
  43. PATH1=$(get_real_path $3)
  44. PATH2=$(get_real_path $4)
  45. if [ ! -d $PATH1 ]
  46. then
  47. echo "error: DATASET_PATH=$PATH1 is not a directory"
  48. exit 1
  49. fi
  50. if [ ! -f $PATH2 ]
  51. then
  52. echo "error: CHECKPOINT_PATH=$PATH2 is not a file"
  53. exit 1
  54. fi
  55. ulimit -u unlimited
  56. export DEVICE_NUM=1
  57. export DEVICE_ID=0
  58. export RANK_SIZE=$DEVICE_NUM
  59. export RANK_ID=0
  60. if [ -d "eval" ];
  61. then
  62. rm -rf ./eval
  63. fi
  64. mkdir ./eval
  65. cp ../*.py ./eval
  66. cp *.sh ./eval
  67. cp -r ../src ./eval
  68. cd ./eval || exit
  69. env > env.log
  70. echo "start evaluation for device $DEVICE_ID"
  71. python eval.py --net=$1 --dataset=$2 --dataset_path=$PATH1 --checkpoint_path=$PATH2 &> log &
  72. cd ..