mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
[osx] fixed mac osx arm64 and x86_64 0.3.0 rpath error (#374)
* Update paddle_inference.cmake * Update process_libraries.py.in * Update process_libraries.py.in * Update paddle_inference.cmake * Update CMakeLists.txt * Update VERSION_NUMBER * Update VERSION_NUMBER * Update download_prebuilt_libraries.md * Update gpu.md * Update cpu.md * Update download_prebuilt_libraries.md * Update jetson.md * Update tensorrt_tricks.md * Update cpp.md Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
@@ -39,7 +39,7 @@ if(NOT MSVC)
|
|||||||
set(CMAKE_CXX_FLAGS "-Wno-format")
|
set(CMAKE_CXX_FLAGS "-Wno-format")
|
||||||
endif(NOT MSVC)
|
endif(NOT MSVC)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX AND (NOT APPLE) AND (NOT ANDROID))
|
||||||
include(${PROJECT_SOURCE_DIR}/cmake/patchelf.cmake)
|
include(${PROJECT_SOURCE_DIR}/cmake/patchelf.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ if(ENABLE_TRT_BACKEND)
|
|||||||
find_package(Python COMPONENTS Interpreter Development REQUIRED)
|
find_package(Python COMPONENTS Interpreter Development REQUIRED)
|
||||||
message(STATUS "Copying ${TRT_DIRECTORY}/lib to ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib ...")
|
message(STATUS "Copying ${TRT_DIRECTORY}/lib to ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib ...")
|
||||||
execute_process(COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/copy_directory.py ${TRT_DIRECTORY}/lib ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib)
|
execute_process(COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/copy_directory.py ${TRT_DIRECTORY}/lib ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib)
|
||||||
if(UNIX)
|
if(UNIX AND (NOT APPLE) AND (NOT ANDROID))
|
||||||
execute_process(COMMAND sh -c "ls *.so*" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib
|
execute_process(COMMAND sh -c "ls *.so*" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib
|
||||||
COMMAND sh -c "xargs ${PATCHELF_EXE} --set-rpath '$ORIGIN'" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib
|
COMMAND sh -c "xargs ${PATCHELF_EXE} --set-rpath '$ORIGIN'" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install/tensorrt/lib
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
|
@@ -88,7 +88,7 @@ ExternalProject_Add(
|
|||||||
${CMAKE_COMMAND} -E copy_directory ${PADDLEINFERENCE_SOURCE_DIR} ${PADDLEINFERENCE_INSTALL_DIR}
|
${CMAKE_COMMAND} -E copy_directory ${PADDLEINFERENCE_SOURCE_DIR} ${PADDLEINFERENCE_INSTALL_DIR}
|
||||||
BUILD_BYPRODUCTS ${PADDLEINFERENCE_COMPILE_LIB})
|
BUILD_BYPRODUCTS ${PADDLEINFERENCE_COMPILE_LIB})
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX AND (NOT APPLE) AND (NOT ANDROID))
|
||||||
add_custom_target(patchelf_paddle_inference ALL COMMAND bash -c "PATCHELF_EXE=${PATCHELF_EXE} python ${PROJECT_SOURCE_DIR}/scripts/patch_paddle_inference.py ${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.so" DEPENDS ${LIBRARY_NAME})
|
add_custom_target(patchelf_paddle_inference ALL COMMAND bash -c "PATCHELF_EXE=${PATCHELF_EXE} python ${PROJECT_SOURCE_DIR}/scripts/patch_paddle_inference.py ${PADDLEINFERENCE_INSTALL_DIR}/paddle/lib/libpaddle_inference.so" DEPENDS ${LIBRARY_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ Linux上编译需满足
|
|||||||
- gcc/g++ >= 5.4(推荐8.2)
|
- gcc/g++ >= 5.4(推荐8.2)
|
||||||
- cmake >= 3.18.0
|
- cmake >= 3.18.0
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy
|
cd FastDeploy
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
@@ -39,16 +39,16 @@ Windows编译需要满足条件
|
|||||||
|
|
||||||
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
||||||
|
|
||||||
```
|
```bat
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy
|
cd FastDeploy
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake .. -G "Visual Studio 16 2019" -A x64 \
|
cmake .. -G "Visual Studio 16 2019" -A x64 ^
|
||||||
-DENABLE_ORT_BACKEND=ON \
|
-DENABLE_ORT_BACKEND=ON ^
|
||||||
-DENABLE_PADDLE_BACKEND=ON \
|
-DENABLE_PADDLE_BACKEND=ON ^
|
||||||
-DENABLE_OPENVINO_BACKEND=ON \
|
-DENABLE_OPENVINO_BACKEND=ON ^
|
||||||
-DENABLE_VISION=ON \
|
-DENABLE_VISION=ON ^
|
||||||
-DCMAKE_INSTALL_PREFIX="D:\Paddle\compiled_fastdeploy"
|
-DCMAKE_INSTALL_PREFIX="D:\Paddle\compiled_fastdeploy" ^
|
||||||
msbuild fastdeploy.sln /m /p:Configuration=Release /p:Platform=x64
|
msbuild fastdeploy.sln /m /p:Configuration=Release /p:Platform=x64
|
||||||
msbuild INSTALL.vcxproj /m /p:Configuration=Release /p:Platform=x64
|
msbuild INSTALL.vcxproj /m /p:Configuration=Release /p:Platform=x64
|
||||||
```
|
```
|
||||||
@@ -68,7 +68,7 @@ msbuild INSTALL.vcxproj /m /p:Configuration=Release /p:Platform=x64
|
|||||||
|
|
||||||
### Linux & Mac
|
### Linux & Mac
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy/python
|
cd FastDeploy/python
|
||||||
export ENABLE_ORT_BACKEND=ON
|
export ENABLE_ORT_BACKEND=ON
|
||||||
@@ -89,7 +89,7 @@ python setup.py bdist_wheel
|
|||||||
|
|
||||||
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
||||||
|
|
||||||
```
|
```bat
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy/python
|
cd FastDeploy/python
|
||||||
set ENABLE_ORT_BACKEND=ON
|
set ENABLE_ORT_BACKEND=ON
|
||||||
|
@@ -16,12 +16,12 @@ FastDeploy提供各平台预编译库,供开发者直接下载安装使用。
|
|||||||
### Python安装
|
### Python安装
|
||||||
|
|
||||||
Release版本(当前最新0.3.0)安装
|
Release版本(当前最新0.3.0)安装
|
||||||
```
|
```bash
|
||||||
pip install fastdeploy-gpu-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html
|
pip install fastdeploy-gpu-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html
|
||||||
```
|
```
|
||||||
|
|
||||||
其中推荐使用Conda配置开发环境
|
其中推荐使用Conda配置开发环境
|
||||||
```
|
```bash
|
||||||
conda config --add channels conda-forge && conda install cudatoolkit=11.2 cudnn=8.2
|
conda config --add channels conda-forge && conda install cudatoolkit=11.2 cudnn=8.2
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ Release版本(当前最新0.3.0)
|
|||||||
### Python安装
|
### Python安装
|
||||||
|
|
||||||
Release版本(当前最新0.3.0)安装
|
Release版本(当前最新0.3.0)安装
|
||||||
```
|
```bash
|
||||||
pip install fastdeploy-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html
|
pip install fastdeploy-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ Release版本(当前最新0.3.0)
|
|||||||
| :--- | :--- | :---- |
|
| :--- | :--- | :---- |
|
||||||
| Linux x64 | [fastdeploy-linux-x64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-x64-0.3.0.tgz) | g++ 8.2编译产出 |
|
| Linux x64 | [fastdeploy-linux-x64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-x64-0.3.0.tgz) | g++ 8.2编译产出 |
|
||||||
| Windows x64 | [fastdeploy-win-x64-0.3.0.zip](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-win-x64-0.3.0.zip) | Visual Studio 16 2019编译产出 |
|
| Windows x64 | [fastdeploy-win-x64-0.3.0.zip](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-win-x64-0.3.0.zip) | Visual Studio 16 2019编译产出 |
|
||||||
| Mac OSX x64 | [fastdeploy-osx-x86_64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-osx-x86_64-0.3.0.tgz) | - |
|
| Mac OSX x64 | [fastdeploy-osx-x86_64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-osx-x86_64-0.3.0.tgz) | clang++ 10.0.0编译产出|
|
||||||
| Mac OSX arm64 | [fastdeploy-osx-arm64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-osx-arm64-0.3.0.tgz) | - |
|
| Mac OSX arm64 | [fastdeploy-osx-arm64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-osx-arm64-0.3.0.tgz) | clang++ 13.0.0编译产出 |
|
||||||
| Linux aarch64 | [fastdeploy-linux-aarch64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-aarch64-0.3.0.tgz) | g++ 6.3.0编译产出 |
|
| Linux aarch64 | [fastdeploy-linux-aarch64-0.3.0.tgz](https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-aarch64-0.3.0.tgz) | g++ 6.3.0编译产出 |
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ Linux上编译需满足
|
|||||||
- cuda >= 11.2
|
- cuda >= 11.2
|
||||||
- cudnn >= 8.2
|
- cudnn >= 8.2
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy
|
cd FastDeploy
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
@@ -50,19 +50,19 @@ Windows编译需要满足条件
|
|||||||
|
|
||||||
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
||||||
|
|
||||||
```
|
```bat
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy
|
cd FastDeploy
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
cmake .. -G "Visual Studio 16 2019" -A x64 \
|
cmake .. -G "Visual Studio 16 2019" -A x64 ^
|
||||||
-DENABLE_ORT_BACKEND=ON \
|
-DENABLE_ORT_BACKEND=ON ^
|
||||||
-DENABLE_PADDLE_BACKEND=ON \
|
-DENABLE_PADDLE_BACKEND=ON ^
|
||||||
-DENABLE_OPENVINO_BACKEND=ON \
|
-DENABLE_OPENVINO_BACKEND=ON ^
|
||||||
-DENABLE_TRT_BACKEND=ON
|
-DENABLE_TRT_BACKEND=ON ^
|
||||||
-DENABLE_VISION=ON \
|
-DENABLE_VISION=ON ^
|
||||||
-DWITH_GPU=ON \
|
-DWITH_GPU=ON ^
|
||||||
-DTRT_DIRECTORY="D:\Paddle\TensorRT-8.4.1.5" \
|
-DTRT_DIRECTORY="D:\Paddle\TensorRT-8.4.1.5" ^
|
||||||
-DCUDA_DIRECTORY="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2" \
|
-DCUDA_DIRECTORY="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2" ^
|
||||||
-DCMAKE_INSTALL_PREFIX="D:\Paddle\compiled_fastdeploy"
|
-DCMAKE_INSTALL_PREFIX="D:\Paddle\compiled_fastdeploy"
|
||||||
msbuild fastdeploy.sln /m /p:Configuration=Release /p:Platform=x64
|
msbuild fastdeploy.sln /m /p:Configuration=Release /p:Platform=x64
|
||||||
msbuild INSTALL.vcxproj /m /p:Configuration=Release /p:Platform=x64
|
msbuild INSTALL.vcxproj /m /p:Configuration=Release /p:Platform=x64
|
||||||
@@ -86,7 +86,7 @@ msbuild INSTALL.vcxproj /m /p:Configuration=Release /p:Platform=x64
|
|||||||
|
|
||||||
所有编译选项通过环境变量导入
|
所有编译选项通过环境变量导入
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy/python
|
cd FastDeploy/python
|
||||||
export ENABLE_ORT_BACKEND=ON
|
export ENABLE_ORT_BACKEND=ON
|
||||||
@@ -113,7 +113,7 @@ python setup.py bdist_wheel
|
|||||||
|
|
||||||
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,执行如下命令
|
||||||
|
|
||||||
```
|
```bat
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy/python
|
cd FastDeploy/python
|
||||||
export ENABLE_ORT_BACKEND=ON
|
export ENABLE_ORT_BACKEND=ON
|
||||||
|
@@ -10,7 +10,7 @@ FastDeploy当前在Jetson仅支持ONNX Runtime CPU和TensorRT GPU两种后端推
|
|||||||
- cmake >= 3.10.0
|
- cmake >= 3.10.0
|
||||||
- jetpack >= 4.6.1
|
- jetpack >= 4.6.1
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy
|
cd FastDeploy
|
||||||
mkdir build && cd build
|
mkdir build && cd build
|
||||||
@@ -34,7 +34,7 @@ make install
|
|||||||
|
|
||||||
所有编译选项通过环境变量导入
|
所有编译选项通过环境变量导入
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
cd FastDeploy/python
|
cd FastDeploy/python
|
||||||
export BUILD_ON_JETSON=ON
|
export BUILD_ON_JETSON=ON
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# TensorRT使用问题
|
# TensorRT使用问题
|
||||||
|
|
||||||
## 1. 运行TensorRT过程中,出现如下日志提示
|
## 1. 运行TensorRT过程中,出现如下日志提示
|
||||||
```
|
```bash
|
||||||
[WARNING] fastdeploy/backends/tensorrt/trt_backend.cc(552)::CreateTrtEngineFromOnnx Cannot build engine right now, because there's dynamic input shape exists, list as below,
|
[WARNING] fastdeploy/backends/tensorrt/trt_backend.cc(552)::CreateTrtEngineFromOnnx Cannot build engine right now, because there's dynamic input shape exists, list as below,
|
||||||
[WARNING] fastdeploy/backends/tensorrt/trt_backend.cc(556)::CreateTrtEngineFromOnnx Input 0: TensorInfo(name: image, shape: [-1, 3, 320, 320], dtype: FDDataType::FP32)
|
[WARNING] fastdeploy/backends/tensorrt/trt_backend.cc(556)::CreateTrtEngineFromOnnx Input 0: TensorInfo(name: image, shape: [-1, 3, 320, 320], dtype: FDDataType::FP32)
|
||||||
[WARNING] fastdeploy/backends/tensorrt/trt_backend.cc(556)::CreateTrtEngineFromOnnx Input 1: TensorInfo(name: scale_factor, shape: [1, 2], dtype: FDDataType::FP32)
|
[WARNING] fastdeploy/backends/tensorrt/trt_backend.cc(556)::CreateTrtEngineFromOnnx Input 1: TensorInfo(name: scale_factor, shape: [1, 2], dtype: FDDataType::FP32)
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
## 1. 获取模型和测试图像
|
## 1. 获取模型和测试图像
|
||||||
|
|
||||||
```
|
```bash
|
||||||
wget https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz
|
wget https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz
|
||||||
wget https://bj.bcebos.com/fastdeploy/tests/test_det.jpg
|
wget https://bj.bcebos.com/fastdeploy/tests/test_det.jpg
|
||||||
tar xvf ppyoloe_crn_l_300e_coco.tgz
|
tar xvf ppyoloe_crn_l_300e_coco.tgz
|
||||||
@@ -16,7 +16,7 @@ tar xvf ppyoloe_crn_l_300e_coco.tgz
|
|||||||
|
|
||||||
如下C++代码保存为`infer_demo.cc`
|
如下C++代码保存为`infer_demo.cc`
|
||||||
|
|
||||||
``` c++
|
```c++
|
||||||
#include "fastdeploy/vision.h"
|
#include "fastdeploy/vision.h"
|
||||||
int main() {
|
int main() {
|
||||||
std::string model_file = "ppyoloe_crn_l_300e_coco/model.pdmodel";
|
std::string model_file = "ppyoloe_crn_l_300e_coco/model.pdmodel";
|
||||||
@@ -49,11 +49,11 @@ FastDeploy中包含多个依赖库,直接采用`g++`或编译器编译较为
|
|||||||
|
|
||||||
假设下载或准备的FastDeploy C++ SDK在`/Paddle/Download`目录下,且目录名为`fastdeploy_cpp_sdk`,在开发者的项目中只需添加如下代码,即可引入`FASTDEPLOY_INCS`和`FASTDEPLOY_LIBS`两个变量,分别表示依赖的头文件和库文件
|
假设下载或准备的FastDeploy C++ SDK在`/Paddle/Download`目录下,且目录名为`fastdeploy_cpp_sdk`,在开发者的项目中只需添加如下代码,即可引入`FASTDEPLOY_INCS`和`FASTDEPLOY_LIBS`两个变量,分别表示依赖的头文件和库文件
|
||||||
|
|
||||||
``` shell
|
```cmake
|
||||||
include(/Paddle/Download/fastdeploy_cpp_sdk/FastDeploy.cmake)
|
include(/Paddle/Download/fastdeploy_cpp_sdk/FastDeploy.cmake)
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```cmake
|
||||||
PROJECT(infer_demo C CXX)
|
PROJECT(infer_demo C CXX)
|
||||||
CMAKE_MINIMUM_REQUIRED (VERSION 3.10)
|
CMAKE_MINIMUM_REQUIRED (VERSION 3.10)
|
||||||
|
|
||||||
@@ -74,23 +74,23 @@ target_link_libraries(infer_demo ${FASTDEPLOY_LIBS})
|
|||||||
|
|
||||||
打开命令行终端,进入`infer_demo.cc`和`CmakeLists.txt`所在的目录,执行如下命令
|
打开命令行终端,进入`infer_demo.cc`和`CmakeLists.txt`所在的目录,执行如下命令
|
||||||
|
|
||||||
```
|
```bash
|
||||||
mkdir build & cd build
|
mkdir build & cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
make -j
|
make -j
|
||||||
```
|
```
|
||||||
|
|
||||||
编译完成后,使用如下命令执行可得到预测结果
|
编译完成后,使用如下命令执行可得到预测结果
|
||||||
```
|
```bash
|
||||||
./infer_demo
|
./infer_demo
|
||||||
```
|
```
|
||||||
执行时如提示`error while loading shared libraries: libxxx.so: cannot open shared object file: No such file...`,说明程序执行时没有找到FastDeploy的库路径,可通过执行如下命令,将FastDeploy的库路径添加到环境变量之后,重新执行二进制程序。
|
执行时如提示`error while loading shared libraries: libxxx.so: cannot open shared object file: No such file...`,说明程序执行时没有找到FastDeploy的库路径,可通过执行如下命令,将FastDeploy的库路径添加到环境变量之后,重新执行二进制程序。
|
||||||
```
|
```bash
|
||||||
source /Path/to/fastdeploy_cpp_sdk/fastdeploy_init.sh
|
source /Path/to/fastdeploy_cpp_sdk/fastdeploy_init.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
执行完屏幕会输出如下日志
|
执行完屏幕会输出如下日志
|
||||||
```
|
```bash
|
||||||
DetectionResult: [xmin, ymin, xmax, ymax, score, label_id]
|
DetectionResult: [xmin, ymin, xmax, ymax, score, label_id]
|
||||||
415.047180,89.311569, 506.009613, 283.863098, 0.950423, 0
|
415.047180,89.311569, 506.009613, 283.863098, 0.950423, 0
|
||||||
163.665710,81.914932, 198.585342, 166.760895, 0.896433, 0
|
163.665710,81.914932, 198.585342, 166.760895, 0.896433, 0
|
||||||
@@ -110,7 +110,7 @@ DetectionResult: [xmin, ymin, xmax, ymax, score, label_id]
|
|||||||
上面的编译过程适用于Linux/Mac,Windows上编译流程如下
|
上面的编译过程适用于Linux/Mac,Windows上编译流程如下
|
||||||
|
|
||||||
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,进入`infer_demo.cc`和`CMakeLists.txt`所在目录,执行如下命令
|
在Windows菜单中,找到`x64 Native Tools Command Prompt for VS 2019`打开,进入`infer_demo.cc`和`CMakeLists.txt`所在目录,执行如下命令
|
||||||
```
|
```bat
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake .. -G "Visual Studio 16 2019" -A x64
|
cmake .. -G "Visual Studio 16 2019" -A x64
|
||||||
@@ -118,7 +118,7 @@ msbuild infer_demo.sln /m /p:Configuration=Release /p:Platform=x64
|
|||||||
```
|
```
|
||||||
|
|
||||||
执行完后,即会在`build/Release`目录下生成`infer_demo.exe`程序,使用如下命令执行可得到预测结果
|
执行完后,即会在`build/Release`目录下生成`infer_demo.exe`程序,使用如下命令执行可得到预测结果
|
||||||
```
|
```bat
|
||||||
Release\infer_demo.exe
|
Release\infer_demo.exe
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -74,6 +74,7 @@ def process_on_linux(current_dir):
|
|||||||
def process_on_mac(current_dir):
|
def process_on_mac(current_dir):
|
||||||
fd_libs = list()
|
fd_libs = list()
|
||||||
libs_path = os.path.join(current_dir, "fastdeploy", "libs")
|
libs_path = os.path.join(current_dir, "fastdeploy", "libs")
|
||||||
|
cmake_build_dir = os.path.join(current_dir, ".setuptools-cmake-build")
|
||||||
for f in os.listdir(libs_path):
|
for f in os.listdir(libs_path):
|
||||||
filename = os.path.join(libs_path, f)
|
filename = os.path.join(libs_path, f)
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
@@ -82,41 +83,48 @@ def process_on_mac(current_dir):
|
|||||||
f.count(".so") > 0):
|
f.count(".so") > 0):
|
||||||
fd_libs.append(filename)
|
fd_libs.append(filename)
|
||||||
|
|
||||||
|
commands = list()
|
||||||
pre_commands = list()
|
pre_commands = list()
|
||||||
for lib in fd_libs:
|
for lib in fd_libs:
|
||||||
pre_commands.append(
|
if lib.count("fastdeploy_main") > 0:
|
||||||
"install_name_tool -delete_rpath '@loader_path/libs' " + lib)
|
pre_commands.append(
|
||||||
|
"install_name_tool -delete_rpath {} ".format(cmake_build_dir) + lib)
|
||||||
|
commands.append("install_name_tool -id @loader_path " + lib)
|
||||||
|
commands.append("install_name_tool -add_rpath @loader_path " + lib)
|
||||||
|
|
||||||
commands = list()
|
|
||||||
third_libs_path = os.path.join(libs_path, "third_libs")
|
third_libs_path = os.path.join(libs_path, "third_libs")
|
||||||
all_libs_paths = [third_libs_path] + user_specified_dirs
|
cmake_third_libs_path = os.path.join(cmake_build_dir, "third_libs", "install")
|
||||||
|
all_libs_paths = [cmake_third_libs_path] + user_specified_dirs
|
||||||
for path in all_libs_paths:
|
for path in all_libs_paths:
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
if d not in ["lib", "lib64"]:
|
if d not in ["lib", "lib64"]:
|
||||||
continue
|
continue
|
||||||
rel_path = os.path.relpath(os.path.join(root, d), libs_path)
|
rel_path = os.path.relpath(os.path.join(root, d), cmake_third_libs_path)
|
||||||
if path in user_specified_dirs:
|
if path in user_specified_dirs:
|
||||||
# Note(zhoushunjie): Use the absolute path for user_specified_dirs
|
# Note(zhoushunjie): Use the absolute path for user_specified_dirs
|
||||||
rpath = os.path.join(root, d)
|
need_delete_rpath = os.path.join(root, d)
|
||||||
|
need_add_rpath = os.path.join(root, d)
|
||||||
else:
|
else:
|
||||||
rpath = "$loader_path/" + rel_path
|
need_delete_rpath = os.path.join(root, d)
|
||||||
|
need_add_rpath = "@loader_path/third_libs/" + rel_path
|
||||||
for lib in fd_libs:
|
for lib in fd_libs:
|
||||||
pre_commands.append(
|
if lib.count("fastdeploy_main") > 0:
|
||||||
"install_name_tool -delete_rpath '@loader_path/{}' {}".format(
|
pre_commands.append(
|
||||||
rpath, lib))
|
"install_name_tool -delete_rpath {} {}".format(need_delete_rpath, lib))
|
||||||
commands.append("install_name_tool -add_rpath 'loader_path/{}' {}".
|
commands.append(
|
||||||
format(rpath, lib))
|
"install_name_tool -add_rpath {} {}".format(need_add_rpath, lib))
|
||||||
|
|
||||||
for cmd in pre_commands:
|
for command in pre_commands:
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(cmd, shell=True)
|
os.system(command)
|
||||||
except:
|
except:
|
||||||
print("Skip execute command:", cmd)
|
print("Skip execute command: " + command)
|
||||||
|
|
||||||
for cmd in commands:
|
for command in commands:
|
||||||
assert subprocess.Popen(
|
assert os.system(
|
||||||
cmd, shell=True) != 0, "Execute command failed: {}".format(cmd)
|
command) == 0, "command execute failed! command: {}".format(
|
||||||
|
command)
|
||||||
|
|
||||||
def process_on_windows(current_dir):
|
def process_on_windows(current_dir):
|
||||||
libs_path = os.path.join(current_dir, "fastdeploy", "libs")
|
libs_path = os.path.join(current_dir, "fastdeploy", "libs")
|
||||||
|
Reference in New Issue
Block a user