From f8c70ed19c07365a8cd5e4d88e47af413b632204 Mon Sep 17 00:00:00 2001 From: LKKlein <1172977438@qq.com> Date: Tue, 3 Nov 2020 20:45:21 +0800 Subject: [PATCH] fix paddle_c path --- deploy/paddleocr-go/README.md | 24 +++++++++++++----------- deploy/paddleocr-go/paddle/common.go | 3 +-- deploy/paddleocr-go/paddle/config.go | 2 -- deploy/paddleocr-go/paddle/predictor.go | 2 -- deploy/paddleocr-go/paddle/tensor.go | 2 -- deploy/paddleocr-go/paddle_c/README.md | 6 ------ 6 files changed, 14 insertions(+), 25 deletions(-) delete mode 100644 deploy/paddleocr-go/paddle_c/README.md diff --git a/deploy/paddleocr-go/README.md b/deploy/paddleocr-go/README.md index 1332c3c0..a82aca57 100644 --- a/deploy/paddleocr-go/README.md +++ b/deploy/paddleocr-go/README.md @@ -150,12 +150,13 @@ make install ```shell # 创建c++推理库文件夹 mkdir -p ~/paddle_inference -export PADDLE_ROOT=`$HOME/paddle_inference` +export PADDLE_INFER=`$HOME/paddle_inference` # 执行编译 +export PADDLE_ROOT=`pwd` mkdir build cd build -cmake -DFLUID_INFERENCE_INSTALL_DIR=$PADDLE_ROOT \ +cmake -DFLUID_INFERENCE_INSTALL_DIR=$PADDLE_INFER \ -DWITH_CONTRIB=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DWITH_PYTHON=OFF \ @@ -178,17 +179,23 @@ build/fluid_inference_c_install_dir └── version.txt ``` -其中`paddle`就是Paddle库的C语言预测API,`version.txt`中包含当前预测库的版本信息。 +其中`paddle`就是Paddle库的C语言预测API,`version.txt`中包含当前预测库的版本信息。最后,将C推理库的动态库和静态库配置到环境变量。 +```shell +echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PADDLE_ROOT/build/fluid_inference_c_install_dir/paddle/lib" >> ~/.bashrc +echo "export LIBRARY_PATH=$LIBRARY_PATH:$PADDLE_ROOT/build/fluid_inference_c_install_dir/paddle/lib" >> ~/.bashrc + +souce ~/.bashrc +``` ## 2. paddleocr-go预测库 ### 2.1 安装paddleocr-go -直接执行安装命令 +确保C推理库已配置到环境变量,然后直接执行安装命令 ```shell -go get github.com/PaddlePaddle/PaddleOCR/deploy/paddleocr-go +go get -u github.com/PaddlePaddle/PaddleOCR/deploy/paddleocr-go ``` ### 2.2 相关使用API @@ -265,15 +272,10 @@ git clone https://github.com/PaddlePaddle/PaddleOCR cd PaddleOCR/deploy/paddleocr-go ``` -- 准备paddle_c环境 - -```shell -cp -r ~/paddle/build/fluid_inference_c_install_dir/* paddle_c/ -``` - - 编译demo ```shell +# 确保C动态库路径已在环境变量中 go build demo.go ``` diff --git a/deploy/paddleocr-go/paddle/common.go b/deploy/paddleocr-go/paddle/common.go index 4bcd443c..ffff739f 100644 --- a/deploy/paddleocr-go/paddle/common.go +++ b/deploy/paddleocr-go/paddle/common.go @@ -1,9 +1,8 @@ package paddle // #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath=\$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c +// #cgo LDFLAGS: -lpaddle_fluid_c // #include -// #include "paddle_c_api.h" import "C" import "fmt" diff --git a/deploy/paddleocr-go/paddle/config.go b/deploy/paddleocr-go/paddle/config.go index 32019239..70f6d33b 100644 --- a/deploy/paddleocr-go/paddle/config.go +++ b/deploy/paddleocr-go/paddle/config.go @@ -1,7 +1,5 @@ package paddle -// #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath,$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c // #include // #include // #include diff --git a/deploy/paddleocr-go/paddle/predictor.go b/deploy/paddleocr-go/paddle/predictor.go index f6cba7bc..9a69c9ee 100644 --- a/deploy/paddleocr-go/paddle/predictor.go +++ b/deploy/paddleocr-go/paddle/predictor.go @@ -1,7 +1,5 @@ package paddle -// #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath,$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c // #include // #include "paddle_c_api.h" import "C" diff --git a/deploy/paddleocr-go/paddle/tensor.go b/deploy/paddleocr-go/paddle/tensor.go index cf462dcd..5c889e5c 100644 --- a/deploy/paddleocr-go/paddle/tensor.go +++ b/deploy/paddleocr-go/paddle/tensor.go @@ -1,7 +1,5 @@ package paddle -// #cgo CFLAGS: -I../paddle_c/paddle/include -// #cgo LDFLAGS: -L${SRCDIR}/../paddle_c/paddle/lib -Wl,-rpath,$ORIGIN/paddle_c/paddle/lib -lpaddle_fluid_c // #include // #include // #include diff --git a/deploy/paddleocr-go/paddle_c/README.md b/deploy/paddleocr-go/paddle_c/README.md deleted file mode 100644 index e3565d6f..00000000 --- a/deploy/paddleocr-go/paddle_c/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Paddle C预测库目录 - -## 编译安装 -使用cmake编译paddle,并打开-DON_INFER=ON,在编译目录下得到paddle_inference_c_install_dir,将该目录下的所有文件复制到本目录下。 - -详细编译步骤请参见[README.md](../README.md) 或者官方文档指导 https://www.paddlepaddle.org.cn/documentation/docs/zh/advanced_guide/inference_deployment/inference/build_and_install_lib_cn.html#id12 \ No newline at end of file -- GitLab