run.sh 2.1 KB
Newer Older
1 2
set -x
PADDLE_ROOT=$1
L
Luo Tao 已提交
3 4
TURN_ON_MKL=$2 # use MKL or Openblas
TEST_GPU_CPU=$3 # test both GPU/CPU mode or only CPU mode
5 6 7 8 9 10
if [ $2 == ON ]; then
  # You can export yourself if move the install path
  MKL_LIB=${PADDLE_ROOT}/build/fluid_install_dir/third_party/install/mklml/lib
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${MKL_LIB}
fi
if [ $3 == ON ]; then
11 12 13 14
  use_gpu_list='true false'
else    
  use_gpu_list='false'
fi
L
Luo Tao 已提交
15

L
Luo Tao 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
# download vis_demo data
function download() {
  dir_name=$1
  mkdir -p $dir_name
  cd $dir_name
  wget -q ${URL_ROOT}$dir_name.tar.gz
  tar xzf *.tar.gz
  cd ..
}
URL_ROOT=http://paddlemodels.bj.bcebos.com/inference-vis-demos%2F
mkdir -p data
cd data
vis_demo_list='se_resnext50 ocr mobilenet'
for vis_demo_name in $vis_demo_list; do
  download $vis_demo_name
done
cd ..

# compile and test the demo
L
Luo Tao 已提交
35 36 37
mkdir -p build
cd build

38
for WITH_STATIC_LIB in ON OFF; do
L
Luo Tao 已提交
39
  # -----simple_on_word2vec-----
L
Luo Tao 已提交
40 41
  rm -rf *
  cmake .. -DPADDLE_LIB=${PADDLE_ROOT}/build/fluid_install_dir/ \
L
Luo Tao 已提交
42
    -DWITH_MKL=$TURN_ON_MKL \
L
Luo Tao 已提交
43
    -DDEMO_NAME=simple_on_word2vec \
L
Luo Tao 已提交
44
    -DWITH_GPU=$TEST_GPU_CPU \
L
Luo Tao 已提交
45
    -DWITH_STATIC_LIB=$WITH_STATIC_LIB
46
  make -j
47 48 49 50 51 52 53 54 55 56 57 58
  word2vec_model=${PADDLE_ROOT}'/build/python/paddle/fluid/tests/book/word2vec.inference.model'
  if [ -d $word2vec_model ]; then
    for use_gpu in $use_gpu_list; do
      ./simple_on_word2vec \
        --dirname=$word2vec_model \
        --use_gpu=$use_gpu
      if [ $? -ne 0 ]; then
        echo "simple_on_word2vec demo runs fail."
        exit 1
      fi
    done
  fi
L
Luo Tao 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
  # ---------vis_demo---------
  rm -rf *
  cmake .. -DPADDLE_LIB=${PADDLE_ROOT}/build/fluid_install_dir/ \
    -DWITH_MKL=$TURN_ON_MKL \
    -DDEMO_NAME=vis_demo \
    -DWITH_GPU=$TEST_GPU_CPU \
    -DWITH_STATIC_LIB=$WITH_STATIC_LIB
  make -j
  for use_gpu in false; do
    for vis_demo_name in $vis_demo_list; do 
      ./vis_demo \
        --modeldir=../data/$vis_demo_name/model \
        --data=../data/$vis_demo_name/data.txt \
        --refer=../data/$vis_demo_name/result.txt \
        --use_gpu=$use_gpu
      if [ $? -ne 0 ]; then
        echo "vis demo $vis_demo_name runs fail."
        exit 1
      fi
    done
  done
80 81
done
set +x