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.

add.sh 2.7 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. export GLOG_v=1
  3. export DEVICE_ID=1
  4. MINDSPORE_INSTALL_PATH=$1
  5. ENV_DEVICE_ID=$DEVICE_ID
  6. CURRPATH=$(cd "$(dirname $0)" || exit; pwd)
  7. CURRUSER=$(whoami)
  8. PROJECT_PATH=${CURRPATH}/../../../
  9. echo "MINDSPORE_INSTALL_PATH:" ${MINDSPORE_INSTALL_PATH}
  10. echo "ENV_DEVICE_ID:" ${ENV_DEVICE_ID}
  11. echo "CURRPATH:" ${CURRPATH}
  12. echo "CURRUSER:" ${CURRUSER}
  13. echo "PROJECT_PATH:" ${PROJECT_PATH}
  14. export LD_LIBRARY_PATH=${MINDSPORE_INSTALL_PATH}/lib:/usr/local/python/python375/lib/:${LD_LIBRARY_PATH}
  15. export PYTHONPATH=${MINDSPORE_INSTALL_PATH}/:${PYTHONPATH}
  16. echo "LD_LIBRARY_PATH: " ${LD_LIBRARY_PATH}
  17. echo "PYTHONPATH: " ${PYTHONPATH}
  18. echo "-------------show MINDSPORE_INSTALL_PATH----------------"
  19. ls -l ${MINDSPORE_INSTALL_PATH}
  20. echo "------------------show /usr/lib64/----------------------"
  21. ls -l /usr/local/python/python375/lib/
  22. clean_pid()
  23. {
  24. ps aux | grep 'master_with_worker.py' | grep ${CURRUSER} | grep -v grep | awk '{print $2}' | xargs kill -9
  25. if [ $? -ne 0 ]
  26. then
  27. echo "clean pip failed"
  28. fi
  29. sleep 6
  30. }
  31. prepare_model()
  32. {
  33. echo "### begin to generate mode for serving test ###"
  34. python3 add_model.py &> add_model.log
  35. echo "### end to generate mode for serving test ###"
  36. result=`find . -name tensor_add.mindir | wc -l`
  37. if [ ${result} -ne 1 ]
  38. then
  39. cat add_model.log
  40. echo "### generate model for serving test failed ###" && exit 1
  41. clean_pid
  42. fi
  43. rm -rf add
  44. mkdir add
  45. mkdir add/1
  46. mv *.mindir ${CURRPATH}/add/1/
  47. cp servable_config.py add/
  48. }
  49. start_service()
  50. {
  51. echo "### start serving service ###"
  52. unset http_proxy https_proxy
  53. python3 master_with_worker.py > service.log 2>&1 &
  54. if [ $? -ne 0 ]
  55. then
  56. echo "server faile to start."
  57. fi
  58. result=`grep -E 'Serving gRPC server start success, listening on 127.0.0.1:5500' service.log | wc -l`
  59. count=0
  60. while [[ ${result} -ne 1 && ${count} -lt 150 ]]
  61. do
  62. sleep 1
  63. count=$(($count+1))
  64. result=`grep -E 'Serving gRPC server start success, listening on 127.0.0.1:5500' service.log | wc -l`
  65. done
  66. if [ ${count} -eq 150 ]
  67. then
  68. clean_pid
  69. cat service.log
  70. echo "start serving service failed!" && exit 1
  71. fi
  72. echo "### start serving service end ###"
  73. }
  74. pytest_serving()
  75. {
  76. unset http_proxy https_proxy
  77. echo "### client start ###"
  78. python3 -m pytest -v -s client.py > client.log 2>&1
  79. if [ $? -ne 0 ]
  80. then
  81. clean_pid
  82. cat client.log
  83. echo "client faile to start." && exit 1
  84. fi
  85. echo "### client end ###"
  86. }
  87. test_bert_model()
  88. {
  89. start_service
  90. pytest_serving
  91. clean_pid
  92. }
  93. echo "-----serving start-----"
  94. rm -rf serving *.log *.mindir *.dat ${CURRPATH}/add ${CURRPATH}/kernel_meta
  95. prepare_model
  96. test_bert_model

A lightweight and high-performance service module that helps MindSpore developers efficiently deploy online inference services in the production environment.