未验证 提交 809ba964 编写于 作者: S Sing_chan 提交者: GitHub

add trt_mobilenet demo test in windows (#37667)

* add trt_mobilenet demo test

* only deliver trt_root in run.sh
上级 07b4fe93
...@@ -19,9 +19,8 @@ PADDLE_ROOT=$1 ...@@ -19,9 +19,8 @@ PADDLE_ROOT=$1
TURN_ON_MKL=$2 # use MKL or Openblas TURN_ON_MKL=$2 # use MKL or Openblas
TEST_GPU_CPU=$3 # test both GPU/CPU mode or only CPU mode TEST_GPU_CPU=$3 # test both GPU/CPU mode or only CPU mode
DATA_DIR=$4 # dataset DATA_DIR=$4 # dataset
TENSORRT_INCLUDE_DIR=$5 # TensorRT header file dir, default to /usr/local/TensorRT/include TENSORRT_ROOT_DIR=$5 # TensorRT root dir, default to /usr
TENSORRT_LIB_DIR=$6 # TensorRT lib file dir, default to /usr/local/TensorRT/lib MSVC_STATIC_CRT=$6
MSVC_STATIC_CRT=$7
inference_install_dir=${PADDLE_ROOT}/build/paddle_inference_install_dir inference_install_dir=${PADDLE_ROOT}/build/paddle_inference_install_dir
WIN_DETECT=$(echo `uname` | grep "Win") # detect current platform WIN_DETECT=$(echo `uname` | grep "Win") # detect current platform
...@@ -39,7 +38,7 @@ else ...@@ -39,7 +38,7 @@ else
fi fi
USE_TENSORRT=OFF USE_TENSORRT=OFF
if [ -d "$TENSORRT_INCLUDE_DIR" -a -d "$TENSORRT_LIB_DIR" ]; then if [ -d "$TENSORRT_ROOT_DIR" ]; then
USE_TENSORRT=ON USE_TENSORRT=ON
fi fi
...@@ -132,6 +131,28 @@ for WITH_STATIC_LIB in ON OFF; do ...@@ -132,6 +131,28 @@ for WITH_STATIC_LIB in ON OFF; do
fi fi
done done
done done
# --------tensorrt mobilenet on windows------
if [ $USE_TENSORRT == ON -a $TEST_GPU_CPU == ON ]; then
rm -rf *
cmake .. -G "Visual Studio 15 2017" -A x64 -T host=x64 -DPADDLE_LIB=${inference_install_dir} \
-DWITH_MKL=$TURN_ON_MKL \
-DDEMO_NAME=trt_mobilenet_demo \
-DWITH_GPU=$TEST_GPU_CPU \
-DWITH_STATIC_LIB=$WITH_STATIC_LIB \
-DMSVC_STATIC_CRT=$MSVC_STATIC_CRT \
-DUSE_TENSORRT=$USE_TENSORRT \
-DTENSORRT_ROOT=$TENSORRT_ROOT_DIR
msbuild /maxcpucount /property:Configuration=Release cpp_inference_demo.sln
Release/trt_mobilenet_demo.exe \
--modeldir=$DATA_DIR/mobilenet/model \
--data=$DATA_DIR/mobilenet/data.txt \
--refer=$DATA_DIR/mobilenet/result.txt
if [ $? -ne 0 ]; then
echo "trt demo trt_mobilenet_demo runs fail."
exit 1
fi
fi
else else
# -----simple_on_word2vec on linux/mac----- # -----simple_on_word2vec on linux/mac-----
rm -rf * rm -rf *
...@@ -183,8 +204,7 @@ for WITH_STATIC_LIB in ON OFF; do ...@@ -183,8 +204,7 @@ for WITH_STATIC_LIB in ON OFF; do
-DWITH_GPU=$TEST_GPU_CPU \ -DWITH_GPU=$TEST_GPU_CPU \
-DWITH_STATIC_LIB=$WITH_STATIC_LIB \ -DWITH_STATIC_LIB=$WITH_STATIC_LIB \
-DUSE_TENSORRT=$USE_TENSORRT \ -DUSE_TENSORRT=$USE_TENSORRT \
-DTENSORRT_INCLUDE_DIR=$TENSORRT_INCLUDE_DIR \ -DTENSORRT_ROOT=$TENSORRT_ROOT_DIR
-DTENSORRT_LIB_DIR=$TENSORRT_LIB_DIR
make -j$(nproc) make -j$(nproc)
./trt_mobilenet_demo \ ./trt_mobilenet_demo \
--modeldir=$DATA_DIR/mobilenet/model \ --modeldir=$DATA_DIR/mobilenet/model \
......
...@@ -741,7 +741,7 @@ for /F %%i in ("%libsize%") do ( ...@@ -741,7 +741,7 @@ for /F %%i in ("%libsize%") do (
) )
cd /d %work_dir%\paddle\fluid\inference\api\demo_ci cd /d %work_dir%\paddle\fluid\inference\api\demo_ci
%cache_dir%\tools\busybox64.exe bash run.sh %work_dir:\=/% %WITH_MKL% %WITH_GPU% %cache_dir:\=/%/inference_demo %TENSORRT_ROOT%/include %TENSORRT_ROOT%/lib %MSVC_STATIC_CRT% %cache_dir%\tools\busybox64.exe bash run.sh %work_dir:\=/% %WITH_MKL% %WITH_GPU% %cache_dir:\=/%/inference_demo %TENSORRT_ROOT% %MSVC_STATIC_CRT%
goto:eof goto:eof
:test_inference_error :test_inference_error
......
...@@ -2236,8 +2236,7 @@ EOF ...@@ -2236,8 +2236,7 @@ EOF
demo_ci_startTime_s=`date +%s` demo_ci_startTime_s=`date +%s`
cd ${PADDLE_ROOT}/paddle/fluid/inference/api/demo_ci cd ${PADDLE_ROOT}/paddle/fluid/inference/api/demo_ci
./run.sh ${PADDLE_ROOT} ${WITH_MKL:-ON} ${WITH_GPU:-OFF} ${INFERENCE_DEMO_INSTALL_DIR} \ ./run.sh ${PADDLE_ROOT} ${WITH_MKL:-ON} ${WITH_GPU:-OFF} ${INFERENCE_DEMO_INSTALL_DIR} \
${TENSORRT_INCLUDE_DIR:-/usr/local/TensorRT/include} \ ${TENSORRT_ROOT_DIR:-/usr}
${TENSORRT_LIB_DIR:-/usr/local/TensorRT/lib}
DEMO_EXIT_CODE=$? DEMO_EXIT_CODE=$?
./clean.sh ./clean.sh
demo_ci_endTime_s=`date +%s` demo_ci_endTime_s=`date +%s`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册