PaddlePaddle / PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
https://paddlepaddle.github.io/PaddleOCR/
Apache License 2.0
44.05k stars 7.81k forks source link

端侧部署中模型优化,得到opt文件失败 #2231

Closed lexiaoyuan closed 3 years ago

lexiaoyuan commented 3 years ago

按照文档执行到2.1模型优化时,编译得到opt文件失败:

root@server82:/Paddle-Lite# git checkout release/v2.7
Already on 'release/v2.7'
Your branch is up-to-date with 'origin/release/v2.7'.
root@server82:/Paddle-Lite# ./lite/tools/build.sh build_optimize_tool
+ readonly 'CMAKE_COMMON_OPTIONS=-DWITH_GPU=OFF                                -DWITH_MKL=OFF                                -DWITH_LITE=ON                                -DLITE_WITH_CUDA=OFF                                -DLITE_WITH_X86=OFF                                -DLITE_WITH_ARM=ON                                -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON'
+ CMAKE_COMMON_OPTIONS='-DWITH_GPU=OFF                                -DWITH_MKL=OFF                                -DWITH_LITE=ON                                -DLITE_WITH_CUDA=OFF                                -DLITE_WITH_X86=OFF                                -DLITE_WITH_ARM=ON                                -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON'
+ readonly NUM_PROC=4
+ NUM_PROC=4
+ BUILD_EXTRA=OFF
+ BUILD_TRAIN=OFF
+ BUILD_JAVA=ON
+ BUILD_PYTHON=OFF
++ pwd
+ BUILD_DIR=/Paddle-Lite
+ OPTMODEL_DIR=
+ BUILD_TAILOR=OFF
+ BUILD_CV=OFF
+ WITH_LOG=ON
+ WITH_MKL=ON
+ WITH_STATIC_MKL=OFF
+ WITH_AVX=ON
+ WITH_EXCEPTION=OFF
+ WITH_PROFILE=OFF
+ BUILD_NPU=OFF
++ pwd
+ NPU_DDK_ROOT=/Paddle-Lite/ai_ddk_lib/
+ BUILD_XPU=OFF
+ BUILD_XTCL=OFF
++ pwd
+ XPU_SDK_ROOT=/Paddle-Lite/xpu_sdk_lib/
+ BUILD_APU=OFF
++ pwd
+ APU_DDK_ROOT=/Paddle-Lite/apu_sdk_lib/
+ BUILD_RKNPU=OFF
++ pwd
+ RKNPU_DDK_ROOT=/Paddle-Lite/rknpu/
+ WITH_HUAWEI_ASCEND_NPU=OFF
+ HUAWEI_ASCEND_NPU_DDK_ROOT=/usr/local/Ascend/ascend-toolkit/latest/x86_64-linux_gcc4.8.5
+ PYTHON_EXECUTABLE_OPTION=
+ IOS_DEPLOYMENT_TARGET=9.0
+ readonly THIRDPARTY_TAR=https://paddle-inference-dist.bj.bcebos.com/PaddleLite/third-party-05b862.tar.gz
+ THIRDPARTY_TAR=https://paddle-inference-dist.bj.bcebos.com/PaddleLite/third-party-05b862.tar.gz
+ readonly workspace=/Paddle-Lite
+ workspace=/Paddle-Lite
++ uname -s
+ os_name=Linux
+ '[' Linux == Darwin ']'
+ main build_optimize_tool
+ '[' -z build_optimize_tool ']'
+ for i in '"$@"'
+ case $i in
+ build_opt
+ cd /Paddle-Lite
+ prepare_thirdparty
+ '[' '!' -d /Paddle-Lite/third-party -o -f /Paddle-Lite/third-party-05b862.tar.gz ']'
+ git submodule update --init --recursive
fatal: destination path 'third-party/flatbuffers' already exists and is not an empty directory.
fatal: clone of 'https://github.com/google/flatbuffers.git' into submodule path 'third-party/flatbuffers' failed

(用自己的数据集训练出了效果不错的模型,现在想部署到移动端) 附:(步骤都是按照教程来的)

# 准备交叉编译环境
docker pull paddlepaddle/paddle-lite:latest

docker run -it \
  --name paddlelite_docker \
  -v $PWD/Paddle-Lite:/Paddle-Lite \
  --net=host \
  paddlepaddle/paddle-lite /bin/bash

# 准备预测库
git clone https://github.com/PaddlePaddle/Paddle-Lite.git
cd Paddle-Lite
# 切换到Paddle-Lite release/v2.7 稳定分支
git checkout release/v2.7
./lite/tools/build_android.sh  --arch=armv8  --with_cv=ON --with_extra=ON

# 启动编译
./lite/tools/build.sh build_optimize_tool
LDOUBLEV commented 3 years ago

看上去是下载第三方库失败了,试试 rm -rf third-party && git checkout third-party,然后再重新编译

lexiaoyuan commented 3 years ago

看上去是下载第三方库失败了,试试 rm -rf third-party && git checkout third-party,然后再重新编译

还是失败,第三方库下载不下载来,有一些第三库中有引用了第三方库,有嵌套,如: image 通过源码编译对于大多数用户来说还是很痛苦的。直接在https://paddle-lite.readthedocs.io/zh/latest/quick_start/release_lib.html#opt下载了opt工具,现在已经可以转换出.nb文件了。

lexiaoyuan commented 3 years ago

解决第三方库下载不成功的办法:

13.250.177.223 github.com

31.13.95.17 github.global.ssl.fastly.Net

sudo vim /etc/hosts sudo /etc/init.d/networking restart

修改git配置

git config --global http.postBuffer 524288000 # httpBuffer加大 git config --global http.maxRequestBuffer 100M git config --global core.compression 0 # 压缩配置

修改配置文件

export GIT_TRACE_PACKET=1 export GIT_TRACE=1 export GIT_CURL_VERBOSE=1

- 然后再尝试
```bash
git checkout release/v2.8
rm -rf third-party && git checkout third-party
./lite/tools/build.sh build_optimize_tool