[win] Add fastdeploy_init.bat and update docs (#320)

* [cmake] support Android arm64-v8a & armeabi-v7a native c++ sdk

* [cmake] fixed patchelf download on mac and android

* [lite] Add threads and power_mode option support

* [pybind] update runtime pybind for lite power mode

* [python] Add set_lite_power_mode api to runtime

* [Lite] add lite enable_fp16 option support

* [lite] add more options for lite backend.

* [cmake] fixed Paddle Lite typo

* [runtime] format LitePowerMode enum comments

* [runtime] format lite option comments

* [win] Add fastdeploy_init.bat and update docs

* [win] Add fastdeploy_init.bat and update docs
This commit is contained in:
DefTruth
2022-10-06 15:57:18 +08:00
committed by GitHub
parent c4288a92e1
commit 584ba3de68
7 changed files with 527 additions and 133 deletions

View File

@@ -49,7 +49,7 @@ if(ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -Os -ffunction-sections -fdata-sections") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -Os -ffunction-sections -fdata-sections")
endif() endif()
#############################CMAKE FOR FASTDEPLOY################################ ############################# Basic Options for FastDeploy ################################
option(ENABLE_PADDLE_FRONTEND "Whether to enable PaddlePaddle frontend to support load paddle model in fastdeploy." ON) option(ENABLE_PADDLE_FRONTEND "Whether to enable PaddlePaddle frontend to support load paddle model in fastdeploy." ON)
option(WITH_GPU "Whether WITH_GPU=ON, will enable onnxruntime-gpu/paddle-infernce-gpu" OFF) option(WITH_GPU "Whether WITH_GPU=ON, will enable onnxruntime-gpu/paddle-infernce-gpu" OFF)
option(ENABLE_ORT_BACKEND "Whether to enable onnxruntime backend." OFF) option(ENABLE_ORT_BACKEND "Whether to enable onnxruntime backend." OFF)
@@ -61,7 +61,7 @@ option(ENABLE_VISION "Whether to enable vision models usage." OFF)
option(ENABLE_VISION_VISUALIZE "Whether to enable visualize vision model result toolbox." ON) option(ENABLE_VISION_VISUALIZE "Whether to enable visualize vision model result toolbox." ON)
option(ENABLE_TEXT "Whether to enable text models usage." OFF) option(ENABLE_TEXT "Whether to enable text models usage." OFF)
option(WITH_TESTING "Whether to compile with unittest." OFF) option(WITH_TESTING "Whether to compile with unittest." OFF)
######################### Options for Android cross compiling #################### ############################# Options for Android cross compiling #########################
option(WITH_OPENCV_STATIC "Use OpenCV static lib for Android." OFF) option(WITH_OPENCV_STATIC "Use OpenCV static lib for Android." OFF)
option(WITH_LITE_STATIC "Use Paddle Lite static lib for Android." OFF) option(WITH_LITE_STATIC "Use Paddle Lite static lib for Android." OFF)
option(WITH_LITE_FULL_API "Use Paddle Lite full API lib for Android." ON) option(WITH_LITE_FULL_API "Use Paddle Lite full API lib for Android." ON)
@@ -156,6 +156,7 @@ if(ANDROID OR IOS)
endif() endif()
endif() endif()
##################################### Buiding: FastDeploy C++ SDK #######################################
add_definitions(-DFASTDEPLOY_LIB) add_definitions(-DFASTDEPLOY_LIB)
# configure files before glob sources. # configure files before glob sources.
configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h) configure_file(${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h.in ${PROJECT_SOURCE_DIR}/${CSRCS_DIR_NAME}/fastdeploy/core/config.h)
@@ -408,6 +409,8 @@ endif()
include(${PROJECT_SOURCE_DIR}/cmake/summary.cmake) include(${PROJECT_SOURCE_DIR}/cmake/summary.cmake)
fastdeploy_summary() fastdeploy_summary()
################################ Installation: FastDeploy C++ SDK ###############################
if(WIN32) if(WIN32)
install( install(
TARGETS ${LIBRARY_NAME} TARGETS ${LIBRARY_NAME}
@@ -437,6 +440,20 @@ install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install
DESTINATION ${CMAKE_INSTALL_PREFIX}/third_libs DESTINATION ${CMAKE_INSTALL_PREFIX}/third_libs
) )
if(WIN32 AND BUILD_EXAMPLES)
get_windows_path(_tmp_install_dir ${CMAKE_CURRENT_BINARY_DIR}/third_libs/install)
get_windows_path(_publish_exe_dir ${EXECUTABLE_OUTPUT_PATH}/Release)
list(GET CMAKE_CONFIGURATION_TYPES 0 _CONFIG_TYPE)
if((${CMAKE_BUILD_TYPE} MATCHES "Release") OR (${_CONFIG_TYPE} MATCHES "Release"))
install(TARGETS ${LIBRARY_NAME} RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH}/Release)
add_custom_target(
copy_fd_third_dlls_examples ALL COMMAND
cmd /C ${PROJECT_SOURCE_DIR}/scripts/fastdeploy_init.bat install ${_tmp_install_dir} ${_publish_exe_dir} noconfirm)
add_dependencies(copy_fd_third_dlls_examples ${LIBRARY_NAME} copy_yaml_library)
endif()
endif()
install( install(
FILES FILES
${PROJECT_SOURCE_DIR}/LICENSE ${PROJECT_SOURCE_DIR}/LICENSE
@@ -447,17 +464,25 @@ install(
${PROJECT_SOURCE_DIR}/cmake/utils.cmake ${PROJECT_SOURCE_DIR}/cmake/utils.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX} DESTINATION ${CMAKE_INSTALL_PREFIX}
) )
install( install(
DIRECTORY ${PROJECT_SOURCE_DIR}/examples DIRECTORY ${PROJECT_SOURCE_DIR}/examples
DESTINATION ${CMAKE_INSTALL_PREFIX} DESTINATION ${CMAKE_INSTALL_PREFIX}
) )
if(NOT WIN32) if(NOT WIN32)
install( install(
FILES ${PROJECT_SOURCE_DIR}/scripts/fastdeploy_init.sh FILES ${PROJECT_SOURCE_DIR}/scripts/fastdeploy_init.sh
DESTINATION ${CMAKE_INSTALL_PREFIX} DESTINATION ${CMAKE_INSTALL_PREFIX}
) )
else()
install(
FILES ${PROJECT_SOURCE_DIR}/scripts/fastdeploy_init.bat
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
endif() endif()
############################### Building: FastDeploy Python Wheel #############################
if(BUILD_FASTDEPLOY_PYTHON) if(BUILD_FASTDEPLOY_PYTHON)
add_definitions(-DBUILD_FASTDEPLOY_PYTHON) add_definitions(-DBUILD_FASTDEPLOY_PYTHON)
if("${PY_EXT_SUFFIX}" STREQUAL "") if("${PY_EXT_SUFFIX}" STREQUAL "")

View File

@@ -76,10 +76,11 @@ endif()
if(ENABLE_OPENVINO_BACKEND) if(ENABLE_OPENVINO_BACKEND)
if (OPENVINO_DIRECTORY) if (OPENVINO_DIRECTORY)
get_openvino_libs(${OPENVINO_DIRECTORY}/runtime) set(OPENVINO_DIR ${OPENVINO_DIRECTORY})
else() else()
get_openvino_libs(${CMAKE_CURRENT_LIST_DIR}/third_libs/install/${OPENVINO_FILENAME}/runtime) set(OPENVINO_DIR ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/${OPENVINO_FILENAME}/runtime)
endif() endif()
get_openvino_libs(${OPENVINO_DIR})
message(STATUS "OPENVINO_LIBS = ${OPENVINO_LIBS}") message(STATUS "OPENVINO_LIBS = ${OPENVINO_LIBS}")
list(APPEND FASTDEPLOY_LIBS ${OPENVINO_LIBS}) list(APPEND FASTDEPLOY_LIBS ${OPENVINO_LIBS})
endif() endif()
@@ -142,7 +143,7 @@ if(ENABLE_VISION)
else() else()
set(OpenCV_DIR ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/${OPENCV_FILENAME}) set(OpenCV_DIR ${CMAKE_CURRENT_LIST_DIR}/third_libs/install/${OPENCV_FILENAME})
if(WIN32) if(WIN32)
set(OpenCV_DIR ${OpenCV_DIR}/build/) set(OpenCV_DIR ${OpenCV_DIR}/build)
endif() endif()
endif() endif()
endif() endif()
@@ -255,9 +256,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif() endif()
endif() endif()
# ------------------------------------------------------------------------------- #
# Usage: install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release) #
# ------------------------------------------------------------------------------- #
function(install_fastdeploy_libraries DESTINATION_DIR) function(install_fastdeploy_libraries DESTINATION_DIR)
set(DYN_LIB_SUFFIX "*.so*") set(DYN_LIB_SUFFIX "*.so*")
if(WIN32) if(WIN32)
@@ -266,12 +264,13 @@ function(install_fastdeploy_libraries DESTINATION_DIR)
set(DYN_LIB_SUFFIX "*.dylib*") set(DYN_LIB_SUFFIX "*.dylib*")
endif() endif()
if(FastDeploy_DIR) if(FastDeploy_DIR)
file(GLOB_RECURSE ALL_NEED_DYN_LIBS ${FastDeploy_DIR}/${DYN_LIB_SUFFIX}) set(DYN_SEARCH_DIR ${FastDeploy_DIR})
elseif(FASTDEPLOY_INSTALL_DIR) elseif(FASTDEPLOY_INSTALL_DIR)
file(GLOB_RECURSE ALL_NEED_DYN_LIBS ${FASTDEPLOY_INSTALL_DIR}/${DYN_LIB_SUFFIX}) set(DYN_SEARCH_DIR ${FASTDEPLOY_INSTALL_DIR})
else() else()
message(FATAL_ERROR "Please set FastDeploy_DIR/FASTDEPLOY_INSTALL_DIR before call install_fastdeploy_libraries.") message(FATAL_ERROR "Please set FastDeploy_DIR/FASTDEPLOY_INSTALL_DIR before call install_fastdeploy_libraries.")
endif() endif()
file(GLOB_RECURSE ALL_NEED_DYN_LIBS ${DYN_SEARCH_DIR}/${DYN_LIB_SUFFIX})
if(ENABLE_VISION) if(ENABLE_VISION)
file(GLOB_RECURSE ALL_OPENCV_DYN_LIBS ${OpenCV_DIR}/${DYN_LIB_SUFFIX}) file(GLOB_RECURSE ALL_OPENCV_DYN_LIBS ${OpenCV_DIR}/${DYN_LIB_SUFFIX})
list(REMOVE_ITEM ALL_NEED_DYN_LIBS ${ALL_OPENCV_DYN_LIBS}) list(REMOVE_ITEM ALL_NEED_DYN_LIBS ${ALL_OPENCV_DYN_LIBS})
@@ -287,6 +286,12 @@ function(install_fastdeploy_libraries DESTINATION_DIR)
file(INSTALL ${OPENCV_DYN_LIBS} DESTINATION ${DESTINATION_DIR}) file(INSTALL ${OPENCV_DYN_LIBS} DESTINATION ${DESTINATION_DIR})
endif() endif()
endif() endif()
if(ENABLE_OPENVINO_BACKEND)
# need plugins.xml for openvino backend
set(OPENVINO_RUNTIME_BIN_DIR ${OPENVINO_DIR}/bin)
file(GLOB OPENVINO_PLUGIN_XML ${OPENVINO_RUNTIME_BIN_DIR}/*.xml)
file(INSTALL ${OPENVINO_PLUGIN_XML} DESTINATION ${DESTINATION_DIR})
endif()
# Install other libraries # Install other libraries
file(INSTALL ${ALL_NEED_DYN_LIBS} DESTINATION ${DESTINATION_DIR}) file(INSTALL ${ALL_NEED_DYN_LIBS} DESTINATION ${DESTINATION_DIR})
endfunction() endfunction()

View File

@@ -180,9 +180,9 @@ else()
endif() endif()
file(RENAME ${THIRD_PARTY_PATH}/install/${OPENCV_FILENAME}/ ${THIRD_PARTY_PATH}/install/opencv) file(RENAME ${THIRD_PARTY_PATH}/install/${OPENCV_FILENAME}/ ${THIRD_PARTY_PATH}/install/opencv)
set(OPENCV_FILENAME opencv) set(OPENCV_FILENAME opencv)
set(OpenCV_DIR ${THIRD_PARTY_PATH}/install/${OPENCV_FILENAME}/) set(OpenCV_DIR ${THIRD_PARTY_PATH}/install/${OPENCV_FILENAME})
if (WIN32) if (WIN32)
set(OpenCV_DIR ${OpenCV_DIR}/build/) set(OpenCV_DIR ${OpenCV_DIR}/build)
endif() endif()
find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR}) find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR})
include_directories(${OpenCV_INCLUDE_DIRS}) include_directories(${OpenCV_INCLUDE_DIRS})

View File

@@ -58,3 +58,8 @@ function(remove_duplicate_libraries libraries)
endforeach() endforeach()
set(${libraries} ${full_libraries} PARENT_SCOPE) set(${libraries} ${full_libraries} PARENT_SCOPE)
endfunction() endfunction()
function(get_windows_path win_path origin_path)
STRING(REGEX REPLACE "/" "\\\\" _win_path ${origin_path})
set(${win_path} ${_win_path} PARENT_SCOPE)
endfunction()

View File

@@ -5,29 +5,33 @@
- 2. 根据开发环境下载预编译部署库和samples代码参考[FastDeploy预编译库](../quick_start) - 2. 根据开发环境下载预编译部署库和samples代码参考[FastDeploy预编译库](../quick_start)
## 目录 ## 目录
- [环境依赖](#Environment) - [1. 环境依赖](#Environment)
- [下载 FastDeploy Windows 10 C++ SDK](#Download) - [2. 下载 FastDeploy Windows 10 C++ SDK](#Download)
- [Windows下多种方式使用 C++ SDK 的方式](#CommandLine) - [3. Windows下多种方式使用 C++ SDK 的方式](#CommandLine)
- [方式一:命令行方式使用 C++ SDK](#CommandLine) - [3.1 命令行方式使用 C++ SDK](#CommandLine)
- [步骤一:在 Windows 命令行终端 上编译 example](#CommandLine) - [3.1.1 在 Windows 命令行终端 上编译 example](#CommandLine)
- [步骤二:运行可执行文件获得推理结果](#CommandLine) - [3.1.2 运行可执行文件获得推理结果](#CommandLine)
- [方式二:Visual Studio 2019 创建sln工程使用 C++ SDK](#VisualStudio2019Sln) - [3.2 Visual Studio 2019 创建sln工程使用 C++ SDK](#VisualStudio2019Sln)
- [步骤一:Visual Studio 2019 创建 sln 工程项目](#VisualStudio2019Sln1) - [3.2.1 Visual Studio 2019 创建 sln 工程项目](#VisualStudio2019Sln1)
- [步骤二:从examples中拷贝infer_ppyoloe.cc的代码到工程](#VisualStudio2019Sln2) - [3.2.2 从examples中拷贝infer_ppyoloe.cc的代码到工程](#VisualStudio2019Sln2)
- [步骤三:将工程配置设置成"Release x64"配置](#VisualStudio2019Sln3) - [3.2.3 将工程配置设置成"Release x64"配置](#VisualStudio2019Sln3)
- [步骤四:配置头文件include路径](#VisualStudio2019Sln4) - [3.2.4 配置头文件include路径](#VisualStudio2019Sln4)
- [步骤五:配置lib路径和添加库文件](#VisualStudio2019Sln5) - [3.2.5 配置lib路径和添加库文件](#VisualStudio2019Sln5)
- [步骤六:编译工程并运行获取结果](#VisualStudio2019Sln6) - [3.2.6 编译工程并运行获取结果](#VisualStudio2019Sln6)
- [方式三:Visual Studio 2019 创建CMake工程使用 C++ SDK](#VisualStudio2019) - [3.3 Visual Studio 2019 创建CMake工程使用 C++ SDK](#VisualStudio2019)
- [步骤一:Visual Studio 2019 创建CMake工程项目](#VisualStudio20191) - [3.3.1 Visual Studio 2019 创建CMake工程项目](#VisualStudio20191)
- [步骤二:在CMakeLists中配置 FastDeploy C++ SDK](#VisualStudio20192) - [3.3.2 在CMakeLists中配置 FastDeploy C++ SDK](#VisualStudio20192)
- [步骤三:生成工程缓存并修改CMakeSetting.json配置](#VisualStudio20193) - [3.3.3 生成工程缓存并修改CMakeSetting.json配置](#VisualStudio20193)
- [步骤四:生成可执行文件,运行获取结果](#VisualStudio20194) - [3.3.4 生成可执行文件,运行获取结果](#VisualStudio20194)
- [方式四CLion IDE 方式使用 C++ SDK](#VisualStudioCode) - [4. 多种方法配置exe运行时所需的依赖库](#CommandLineDeps1)
- [多种方法配置exe运行时所需的依赖库](#CommandLineDeps1) - [4.1 使用 fastdeploy_init.bat 进行配置(推荐)](#CommandLineDeps1)
- [方式一修改CMakeLists.txt一行命令配置推荐](#CommandLineDeps1) - [4.1.1 fastdeploy_init.bat 使用说明](#CommandLineDeps11)
- [方式二:命令行设置环境变量](#CommandLineDeps2) - [4.1.2 fastdeploy_init.bat 查看 SDK 中所有的 dll、lib 和 include 路径](#CommandLineDeps12)
- [方法三手动拷贝依赖库到exe的目录](#CommandLineDeps3) - [4.1.3 fastdeploy_init.bat 安装 SDK 中所有的 dll 到指定的目录](#CommandLineDeps13)
- [4.1.4 fastdeploy_init.bat 配置 SDK 环境变量](#CommandLineDeps14)
- [4.2 修改 CMakeLists.txt一行命令配置推荐](#CommandLineDeps2)
- [4.3 命令行设置环境变量](#CommandLineDeps3)
- [4.4 手动拷贝依赖库到exe的目录下](#CommandLineDeps4)
## 1. 环境依赖 ## 1. 环境依赖
@@ -41,21 +45,24 @@
## 2. 下载 FastDeploy Windows 10 C++ SDK ## 2. 下载 FastDeploy Windows 10 C++ SDK
<div id="Download"></div> <div id="Download"></div>
### 2.1 下载预编译库或者从源码编译最新的SDK
可以从以下链接下载编译好的 FastDeploy Windows 10 C++ SDKSDK中包含了examples代码。 可以从以下链接下载编译好的 FastDeploy Windows 10 C++ SDKSDK中包含了examples代码。
```text ```text
https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-win-x64-gpu-0.2.1.zip https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-win-x64-gpu-0.2.1.zip
``` ```
## 3. 准备模型文件和测试图片 源码编译请参考: [Windows C++ SDK源码编译文档](./how_to_build_windows.md)
### 2.2 准备模型文件和测试图片
可以从以下链接下载模型文件和测试图片,并解压缩 可以从以下链接下载模型文件和测试图片,并解压缩
```text ```text
https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz # (下载后解压缩) https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz # (下载后解压缩)
https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
``` ```
## 4. SDK使用方式一命令行方式使用 C++ SDK ## 3. Windows下多种方式使用 C++ SDK 的方式
### 3.1 SDK使用方式一命令行方式使用 C++ SDK
<div id="CommandLine"></div> <div id="CommandLine"></div>
### 4.1 在 Windows 上编译 PPYOLOE #### 3.1.1 在 Windows 上编译 PPYOLOE
Windows菜单打开`x64 Native Tools Command Prompt for VS 2019`命令工具cd到ppyoloe的demo路径 Windows菜单打开`x64 Native Tools Command Prompt for VS 2019`命令工具cd到ppyoloe的demo路径
```bat ```bat
cd fastdeploy-win-x64-gpu-0.2.1\examples\vision\detection\paddledetection\cpp cd fastdeploy-win-x64-gpu-0.2.1\examples\vision\detection\paddledetection\cpp
@@ -69,7 +76,7 @@ cmake .. -G "Visual Studio 16 2019" -A x64 -DFASTDEPLOY_INSTALL_DIR=%cd%\..\..\.
msbuild infer_demo.sln /m:4 /p:Configuration=Release /p:Platform=x64 msbuild infer_demo.sln /m:4 /p:Configuration=Release /p:Platform=x64
``` ```
### 4.2 运行 demo #### 3.1.2 运行 demo
```bat ```bat
cd Release cd Release
infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 0 # CPU infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 0 # CPU
@@ -79,13 +86,13 @@ infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 2 # GPU + Tenso
特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps) 特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps)
## 5. SDK使用方式二Visual Studio 2019 创建 sln 工程使用 C++ SDK ### 3.2 SDK使用方式二Visual Studio 2019 创建 sln 工程使用 C++ SDK
本章节针对非CMake用户介绍如何在Visual Studio 2019 中创建 sln 工程使用 FastDeploy C++ SDK. CMake用户请直接看下一章节。另外本章节内容特别感谢“梦醒南天”同学关于FastDeploy使用的文档教程[如何在 Windows 上使用 FastDeploy C++ 部署 PaddleDetection 目标检测模型](https://www.bilibili.com/read/cv18807232) 本章节针对非CMake用户介绍如何在Visual Studio 2019 中创建 sln 工程使用 FastDeploy C++ SDK. CMake用户请直接看下一章节。另外本章节内容特别感谢“梦醒南天”同学关于FastDeploy使用的文档教程[如何在 Windows 上使用 FastDeploy C++ 部署 PaddleDetection 目标检测模型](https://www.bilibili.com/read/cv18807232)
<div id="VisualStudio2019Sln"></div> <div id="VisualStudio2019Sln"></div>
### 5.1 步骤一Visual Studio 2019 创建 sln 工程项目 #### 3.2.1 步骤一Visual Studio 2019 创建 sln 工程项目
<div id="VisualStudio2019Sln1"></div> <div id="VisualStudio2019Sln1"></div>
@@ -99,7 +106,7 @@ infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 2 # GPU + Tenso
![image](https://user-images.githubusercontent.com/31974251/192817382-643c8ca2-1f2a-412e-954e-576c22b4ea62.png) ![image](https://user-images.githubusercontent.com/31974251/192817382-643c8ca2-1f2a-412e-954e-576c22b4ea62.png)
### 5.2 步骤二从examples中拷贝infer_ppyoloe.cc的代码到工程 #### 3.2.2 步骤二从examples中拷贝infer_ppyoloe.cc的代码到工程
<div id="VisualStudio2019Sln2"></div> <div id="VisualStudio2019Sln2"></div>
@@ -110,13 +117,13 @@ fastdeploy-win-x64-gpu-0.2.1\examples\vision\detection\paddledetection\cpp
![image](https://user-images.githubusercontent.com/31974251/192818456-21ca846c-ab52-4001-96d2-77c8174bff6b.png) ![image](https://user-images.githubusercontent.com/31974251/192818456-21ca846c-ab52-4001-96d2-77c8174bff6b.png)
### 5.3 步骤三:将工程配置设置成"Release x64"配置 #### 3.2.3 步骤三:将工程配置设置成"Release x64"配置
<div id="VisualStudio2019Sln3"></div> <div id="VisualStudio2019Sln3"></div>
![image](https://user-images.githubusercontent.com/31974251/192818918-98d7a54c-4a60-4760-a3cb-ecacc38b7e7a.png) ![image](https://user-images.githubusercontent.com/31974251/192818918-98d7a54c-4a60-4760-a3cb-ecacc38b7e7a.png)
### 5.4 步骤四配置头文件include路径 #### 3.2.4 步骤四配置头文件include路径
<div id="VisualStudio2019Sln4"></div> <div id="VisualStudio2019Sln4"></div>
@@ -143,7 +150,7 @@ D:\qiuyanjun\fastdeploy_build\built\fastdeploy-win-x64-gpu-0.2.1\third_libs\inst
用户需要根据自己实际的sdk路径稍作修改。 用户需要根据自己实际的sdk路径稍作修改。
### 5.5 步骤五配置lib路径和添加库文件 #### 3.2.5 步骤五配置lib路径和添加库文件
<div id="VisualStudio2019Sln5"></div> <div id="VisualStudio2019Sln5"></div>
@@ -163,7 +170,7 @@ D:\qiuyanjun\fastdeploy_build\built\fastdeploy-win-x64-gpu-0.2.1\third_libs\inst
![image](https://user-images.githubusercontent.com/31974251/192826884-44fc84a1-c57a-45f1-8ee2-30b7eaa3dce9.png) ![image](https://user-images.githubusercontent.com/31974251/192826884-44fc84a1-c57a-45f1-8ee2-30b7eaa3dce9.png)
### 5.6 步骤六:编译工程并运行获取结果 #### 3.2.6 步骤六:编译工程并运行获取结果
<div id="VisualStudio2019Sln6"></div> <div id="VisualStudio2019Sln6"></div>
@@ -184,12 +191,12 @@ D:\qiuyanjun\fastdeploy_test\infer_ppyoloe\x64\Release\infer_ppyoloe.exe
![image](https://user-images.githubusercontent.com/31974251/192829545-3ea36bfc-9a54-492b-984b-2d5d39094d47.png) ![image](https://user-images.githubusercontent.com/31974251/192829545-3ea36bfc-9a54-492b-984b-2d5d39094d47.png)
## 6. SDK使用方式三Visual Studio 2019 创建 CMake 工程使用 C++ SDK ### 3.3 SDK使用方式三Visual Studio 2019 创建 CMake 工程使用 C++ SDK
<div id="VisualStudio2019"></div> <div id="VisualStudio2019"></div>
本章节针对CMake用户介绍如何在Visual Studio 2019 中创建 CMake 工程使用 FastDeploy C++ SDK. 本章节针对CMake用户介绍如何在Visual Studio 2019 中创建 CMake 工程使用 FastDeploy C++ SDK.
### 6.1 步骤一Visual Studio 2019 创建“CMake”工程项目 #### 3.3.1 步骤一Visual Studio 2019 创建“CMake”工程项目
<div id="VisualStudio20191"></div> <div id="VisualStudio20191"></div>
@@ -206,7 +213,7 @@ D:\qiuyanjun\fastdeploy_test\infer_ppyoloe\x64\Release\infer_ppyoloe.exe
![image](https://user-images.githubusercontent.com/31974251/192143930-db1655c2-66ee-448c-82cb-0103ca1ca2a0.png) ![image](https://user-images.githubusercontent.com/31974251/192143930-db1655c2-66ee-448c-82cb-0103ca1ca2a0.png)
### 6.2 步骤二在CMakeLists中配置 FastDeploy C++ SDK #### 3.3.2 步骤二在CMakeLists中配置 FastDeploy C++ SDK
<div id="VisualStudio20192"></div> <div id="VisualStudio20192"></div>
@@ -246,7 +253,7 @@ install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release)
``` ```
注意,`install_fastdeploy_libraries`函数仅在最新的代码编译的SDK或版本>0.2.1下有效。 注意,`install_fastdeploy_libraries`函数仅在最新的代码编译的SDK或版本>0.2.1下有效。
### 6.3 步骤三生成工程缓存并修改CMakeSetting.json配置 #### 3.3.3 步骤三生成工程缓存并修改CMakeSetting.json配置
<div id="VisualStudio20193"></div> <div id="VisualStudio20193"></div>
@@ -277,7 +284,7 @@ install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release)
![image](https://user-images.githubusercontent.com/31974251/192146239-a1eacd9e-034d-4373-a262-65b18ce25b87.png) ![image](https://user-images.githubusercontent.com/31974251/192146239-a1eacd9e-034d-4373-a262-65b18ce25b87.png)
### 6.4 步骤四:生成可执行文件,运行获取结果。 #### 3.3.4 步骤四:生成可执行文件,运行获取结果。
<div id="VisualStudio20194"></div> <div id="VisualStudio20194"></div>
@@ -319,20 +326,116 @@ Visualized result saved in ./vis_result.jpg
特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps) 特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps)
## 7. 多种方法配置exe运行时所需的依赖库 ## 4. 多种方法配置exe运行时所需的依赖库
<div id="CommandLineDeps"></div> <div id="CommandLineDeps"></div>
说明对于使用的最新源码编译的SDK或SDK版本>0.2.1的用户我们推荐使用4.14.2中的方式配置运行时的依赖库。如果使用的SDK版本<=0.2.1请参考4.34.4)中的方式进行配置。
### 7.1 方式一:修改CMakeLists.txt一行命令配置(推荐) ### 4.1 方式一:使用 fastdeploy_init.bat 进行配置推荐
<div id="CommandLineDeps1"></div> <div id="CommandLineDeps1"></div>
对于版本高于0.2.1的SDK我们提供了 **fastdeploy_init.bat** 工具来管理FastDeploy中所有的依赖库。可以通过该脚本工具查看(show)、拷贝(install) 和 设置(init and setup) SDK中所有的dll方便用户快速完成运行时环境配置。
#### 4.1.1 fastdeploy_init.bat 使用说明
<div id="CommandLineDeps11"></div>
首先进入SDK的根目录运行以下命令可以查看 fastdeploy_init.bat 的用法说明
```bat
D:\path-to-your-fastdeploy-sdk-dir>fastdeploy_init.bat help
------------------------------------------------------------------------------------------------------------------------------------------------------------
[1] [help] print help information: fastdeploy_init.bat help
[2] [show] show all dlls/libs/include paths: fastdeploy_init.bat show fastdeploy-sdk-dir
[3] [init] init all dlls paths for current terminal: fastdeploy_init.bat init fastdeploy-sdk-dir [WARNING: need copy onnxruntime.dll manually]
[4] [setup] setup path env for current terminal: fastdeploy_init.bat setup fastdeploy-sdk-dir [WARNING: need copy onnxruntime.dll manually]
[5] [install] install all dlls to a specific dir: fastdeploy_init.bat install fastdeploy-sdk-dir another-dir-to-install-dlls **[RECOMMEND]**
[6] [install] install all dlls with logging infos: fastdeploy_init.bat install fastdeploy-sdk-dir another-dir-to-install-dlls info
------------------------------------------------------------------------------------------------------------------------------------------------------------
```
用法简要说明如下:
- help: 打印所有的用法说明
- show: 查看SDK中所有的 dll、lib 和 include 路径
- init: 初始化所有dll路径信息后续用于设置terminal环境变量不推荐请参考4.3中关于onnxruntime的说明
- setup: 在init之后运行设置terminal环境便令不推荐请参考4.3中关于onnxruntime的说明
- install: 将SDK中所有的dll安装到某个指定的目录推荐
#### 4.1.2 fastdeploy_init.bat 查看 SDK 中所有的 dll、lib 和 include 路径
<div id="CommandLineDeps12"></div>
进入SDK的根目录运行show命令可以查看SDK中所有的 dll、lib 和 include 路径。以下命令中 %cd% 表示当前目录SDK的根目录
```bat
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat show %cd%
------------------------------------------------------------------------------------------------------------------------------------------------------------
[SDK] D:\path-to-fastdeploy-sdk-dir
------------------------------------------------------------------------------------------------------------------------------------------------------------
[DLL] D:\path-to-fastdeploy-sdk-dir\lib\fastdeploy.dll **[NEEDED]**
[DLL] D:\path-to-fastdeploy-sdk-dir\third_libs\install\faster_tokenizer\lib\core_tokenizers.dll **[NEEDED]**
[DLL] D:\path-to-fastdeploy-sdk-dir\third_libs\install\opencv\build\x64\vc15\bin\opencv_ffmpeg3416_64.dll **[NEEDED]**
......
------------------------------------------------------------------------------------------------------------------------------------------------------------
[Lib] D:\path-to-fastdeploy-sdk-dir\lib\fastdeploy.lib **[NEEDED][fastdeploy]**
[Lib] D:\path-to-fastdeploy-sdk-dir\third_libs\install\faster_tokenizer\lib\core_tokenizers.lib **[NEEDED][fastdeploy::text]**
[Lib] D:\path-to-fastdeploy-sdk-dir\third_libs\install\opencv\build\x64\vc15\lib\opencv_world3416.lib **[NEEDED][fastdeploy::vision]**
......
------------------------------------------------------------------------------------------------------------------------------------------------------------
[Include] D:\path-to-fastdeploy-sdk-dir\include **[NEEDED][fastdeploy]**
[Include] D:\path-to-fastdeploy-sdk-dir\third_libs\install\faster_tokenizer\include **[NEEDED][fastdeploy::text]**
[Include] D:\path-to-fastdeploy-sdk-dir\third_libs\install\opencv\build\include **[NEEDED][fastdeploy::vision]**
......
------------------------------------------------------------------------------------------------------------------------------------------------------------
[XML] D:\path-to-fastdeploy-sdk-dir\third_libs\install\openvino\runtime\bin\plugins.xml **[NEEDED]**
------------------------------------------------------------------------------------------------------------------------------------------------------------
```
可以看到该命令会根据您当前的SDK输出对应的信息包含 dll、lib 和 include 的路径信息。对于 dll被标记为 `[NEEDED]`的是运行时所需要的如果包含OpenVINO后端还需要将他的plugins.xml拷贝到exe所在的目录对于 lib 和 include被标记为`[NEEDED]`的是开发时所需要配置的最小依赖。并且我们还增加了对应的API Tag标记如果您只使用vision API则只需要配置标记为 `[NEEDED][fastdeploy::vision]` 的 lib 和 include 路径.
#### 4.1.3 fastdeploy_init.bat 安装 SDK 中所有的 dll 到指定的目录 (推荐)
<div id="CommandLineDeps13"></div>
进入SDK的根目录运行install命令可以将SDK 中所有的 dll 安装到指定的目录如exe所在的目录。我们推荐这种方式来配置exe运行所需要的依赖库。比如可以在SDK根目录下创建一个临时的bin目录备份所有的dll文件。以下命令中 %cd% 表示当前目录SDK的根目录
```bat
% info参数为可选参数添加info参数后会打印详细的安装信息 %
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat install %cd% bin
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat install %cd% bin info
```
```bat
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat install %cd% bin
[INFO] Do you want to install all FastDeploy dlls ?
[INFO] From: D:\path-to-fastdeploy-sdk-dir
[INFO] To: bin
Choose y means YES, n means NO: [y/n]y
YES.
请按任意键继续. . .
[INFO] Created bin done!
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
.....
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
.....
```
#### 4.1.4 fastdeploy_init.bat 配置 SDK 环境变量
<div id="CommandLineDeps14"></div>
您也可以选择通过配置环境变量的方式来设置运行时的依赖库环境这种方式只在当前的terminal有效。如果您使用的SDK中包含了onnxruntime推理后端我们不推荐这种方式详细原因请参考4.3中关于onnxruntime配置的说明需要手动拷贝onnxruntime所有的dll到exe所在的目录。配置 SDK 环境变量的方式如下。以下命令中 %cd% 表示当前目录SDK的根目录
```bat
% 先运行 init 初始化当前SDK所有的dll文件路径 %
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat init %cd%
% 再运行 setup 完成 SDK 环境变量配置 %
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat setup %cd%
```
### 4.2 方式二修改CMakeLists.txt一行命令配置推荐
<div id="CommandLineDeps2"></div>
考虑到Windows下C++开发的特殊性如经常需要拷贝所有的lib或dll文件到某个指定的目录FastDeploy提供了`install_fastdeploy_libraries`的cmake函数方便用户快速配置所有的dll。修改ppyoloe的CMakeLists.txt添加 考虑到Windows下C++开发的特殊性如经常需要拷贝所有的lib或dll文件到某个指定的目录FastDeploy提供了`install_fastdeploy_libraries`的cmake函数方便用户快速配置所有的dll。修改ppyoloe的CMakeLists.txt添加
```cmake ```cmake
install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release) install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release)
``` ```
注意该方式仅在最新的代码编译的SDK或版本>0.2.1下有效。 注意该方式仅在最新的代码编译的SDK或版本>0.2.1下有效。
### 7.2 方式:命令行设置环境变量 ### 4.3 方式:命令行设置环境变量
<div id="CommandLineDeps2"></div> <div id="CommandLineDeps3"></div>
编译好的exe保存在Release目录下在运行demo前需要将模型和测试图片拷贝至该目录。另外需要在终端指定DLL的搜索路径。请在build目录下执行以下命令。 编译好的exe保存在Release目录下在运行demo前需要将模型和测试图片拷贝至该目录。另外需要在终端指定DLL的搜索路径。请在build目录下执行以下命令。
```bat ```bat
@@ -371,9 +474,9 @@ set PATH=%FASTDEPLOY_HOME%\third_libs\install\openvino\runtime\3rdparty\tbb\bin;
setup_fastdeploy_dll.bat setup_fastdeploy_dll.bat
``` ```
### 7.3 方式手动拷贝依赖库到exe的目录下 ### 4.4 方式手动拷贝依赖库到exe的目录下
<div id="CommandLineDeps3"></div> <div id="CommandLineDeps4"></div>
手动拷贝或者在build目录下执行以下命令 手动拷贝或者在build目录下执行以下命令
```bat ```bat
@@ -404,10 +507,3 @@ copy /Y %FASTDEPLOY_HOME%\third_libs\install\openvino\runtime\3rdparty\tbb\bin\*
copy_fastdeploy_dll.bat copy_fastdeploy_dll.bat
``` ```
特别说明上述的set和copy命令对应的依赖库路径需要用户根据自己使用SDK中的依赖库进行适当地修改。比如若是CPU版本的SDK则不需要TensorRT相关的设置。 特别说明上述的set和copy命令对应的依赖库路径需要用户根据自己使用SDK中的依赖库进行适当地修改。比如若是CPU版本的SDK则不需要TensorRT相关的设置。
## 8. CLion 2022 IDE 方式使用 C++ SDK
<div id="CLion"></div>
- TODO

View File

@@ -5,29 +5,33 @@
- 2. 根据开发环境下载预编译部署库和samples代码参考[FastDeploy预编译库](../quick_start) - 2. 根据开发环境下载预编译部署库和samples代码参考[FastDeploy预编译库](../quick_start)
## 目录 ## 目录
- [环境依赖](#Environment) - [1. 环境依赖](#Environment)
- [下载 FastDeploy Windows 10 C++ SDK](#Download) - [2. 下载 FastDeploy Windows 10 C++ SDK](#Download)
- [Windows下多种方式使用 C++ SDK 的方式](#CommandLine) - [3. Windows下多种方式使用 C++ SDK 的方式](#CommandLine)
- [方式一:命令行方式使用 C++ SDK](#CommandLine) - [3.1 命令行方式使用 C++ SDK](#CommandLine)
- [步骤一:在 Windows 命令行终端 上编译 example](#CommandLine) - [3.1.1 在 Windows 命令行终端 上编译 example](#CommandLine)
- [步骤二:运行可执行文件获得推理结果](#CommandLine) - [3.1.2 运行可执行文件获得推理结果](#CommandLine)
- [方式二:Visual Studio 2019 创建sln工程使用 C++ SDK](#VisualStudio2019Sln) - [3.2 Visual Studio 2019 创建sln工程使用 C++ SDK](#VisualStudio2019Sln)
- [步骤一:Visual Studio 2019 创建 sln 工程项目](#VisualStudio2019Sln1) - [3.2.1 Visual Studio 2019 创建 sln 工程项目](#VisualStudio2019Sln1)
- [步骤二:从examples中拷贝infer_ppyoloe.cc的代码到工程](#VisualStudio2019Sln2) - [3.2.2 从examples中拷贝infer_ppyoloe.cc的代码到工程](#VisualStudio2019Sln2)
- [步骤三:将工程配置设置成"Release x64"配置](#VisualStudio2019Sln3) - [3.2.3 将工程配置设置成"Release x64"配置](#VisualStudio2019Sln3)
- [步骤四:配置头文件include路径](#VisualStudio2019Sln4) - [3.2.4 配置头文件include路径](#VisualStudio2019Sln4)
- [步骤五:配置lib路径和添加库文件](#VisualStudio2019Sln5) - [3.2.5 配置lib路径和添加库文件](#VisualStudio2019Sln5)
- [步骤六:编译工程并运行获取结果](#VisualStudio2019Sln6) - [3.2.6 编译工程并运行获取结果](#VisualStudio2019Sln6)
- [方式三:Visual Studio 2019 创建CMake工程使用 C++ SDK](#VisualStudio2019) - [3.3 Visual Studio 2019 创建CMake工程使用 C++ SDK](#VisualStudio2019)
- [步骤一:Visual Studio 2019 创建CMake工程项目](#VisualStudio20191) - [3.3.1 Visual Studio 2019 创建CMake工程项目](#VisualStudio20191)
- [步骤二:在CMakeLists中配置 FastDeploy C++ SDK](#VisualStudio20192) - [3.3.2 在CMakeLists中配置 FastDeploy C++ SDK](#VisualStudio20192)
- [步骤三:生成工程缓存并修改CMakeSetting.json配置](#VisualStudio20193) - [3.3.3 生成工程缓存并修改CMakeSetting.json配置](#VisualStudio20193)
- [步骤四:生成可执行文件,运行获取结果](#VisualStudio20194) - [3.3.4 生成可执行文件,运行获取结果](#VisualStudio20194)
- [方式四CLion IDE 方式使用 C++ SDK](#VisualStudioCode) - [4. 多种方法配置exe运行时所需的依赖库](#CommandLineDeps1)
- [多种方法配置exe运行时所需的依赖库](#CommandLineDeps1) - [4.1 使用 fastdeploy_init.bat 进行配置(推荐)](#CommandLineDeps1)
- [方式一修改CMakeLists.txt一行命令配置推荐](#CommandLineDeps1) - [4.1.1 fastdeploy_init.bat 使用说明](#CommandLineDeps11)
- [方式二:命令行设置环境变量](#CommandLineDeps2) - [4.1.2 fastdeploy_init.bat 查看 SDK 中所有的 dll、lib 和 include 路径](#CommandLineDeps12)
- [方法三手动拷贝依赖库到exe的目录](#CommandLineDeps3) - [4.1.3 fastdeploy_init.bat 安装 SDK 中所有的 dll 到指定的目录](#CommandLineDeps13)
- [4.1.4 fastdeploy_init.bat 配置 SDK 环境变量](#CommandLineDeps14)
- [4.2 修改 CMakeLists.txt一行命令配置推荐](#CommandLineDeps2)
- [4.3 命令行设置环境变量](#CommandLineDeps3)
- [4.4 手动拷贝依赖库到exe的目录下](#CommandLineDeps4)
## 1. 环境依赖 ## 1. 环境依赖
@@ -41,21 +45,24 @@
## 2. 下载 FastDeploy Windows 10 C++ SDK ## 2. 下载 FastDeploy Windows 10 C++ SDK
<div id="Download"></div> <div id="Download"></div>
### 2.1 下载预编译库或者从源码编译最新的SDK
可以从以下链接下载编译好的 FastDeploy Windows 10 C++ SDKSDK中包含了examples代码。 可以从以下链接下载编译好的 FastDeploy Windows 10 C++ SDKSDK中包含了examples代码。
```text ```text
https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-win-x64-gpu-0.2.1.zip https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-win-x64-gpu-0.2.1.zip
``` ```
## 3. 准备模型文件和测试图片 源码编译请参考: [Windows C++ SDK源码编译文档](../compile/how_to_build_windows.md)
### 2.2 准备模型文件和测试图片
可以从以下链接下载模型文件和测试图片,并解压缩 可以从以下链接下载模型文件和测试图片,并解压缩
```text ```text
https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz # (下载后解压缩) https://bj.bcebos.com/paddlehub/fastdeploy/ppyoloe_crn_l_300e_coco.tgz # (下载后解压缩)
https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
``` ```
## 4. SDK使用方式一命令行方式使用 C++ SDK ## 3. Windows下多种方式使用 C++ SDK 的方式
### 3.1 SDK使用方式一命令行方式使用 C++ SDK
<div id="CommandLine"></div> <div id="CommandLine"></div>
### 4.1 在 Windows 上编译 PPYOLOE #### 3.1.1 在 Windows 上编译 PPYOLOE
Windows菜单打开`x64 Native Tools Command Prompt for VS 2019`命令工具cd到ppyoloe的demo路径 Windows菜单打开`x64 Native Tools Command Prompt for VS 2019`命令工具cd到ppyoloe的demo路径
```bat ```bat
cd fastdeploy-win-x64-gpu-0.2.1\examples\vision\detection\paddledetection\cpp cd fastdeploy-win-x64-gpu-0.2.1\examples\vision\detection\paddledetection\cpp
@@ -69,7 +76,7 @@ cmake .. -G "Visual Studio 16 2019" -A x64 -DFASTDEPLOY_INSTALL_DIR=%cd%\..\..\.
msbuild infer_demo.sln /m:4 /p:Configuration=Release /p:Platform=x64 msbuild infer_demo.sln /m:4 /p:Configuration=Release /p:Platform=x64
``` ```
### 4.2 运行 demo #### 3.1.2 运行 demo
```bat ```bat
cd Release cd Release
infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 0 # CPU infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 0 # CPU
@@ -79,13 +86,13 @@ infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 2 # GPU + Tenso
特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps) 特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps)
## 5. SDK使用方式二Visual Studio 2019 创建 sln 工程使用 C++ SDK ### 3.2 SDK使用方式二Visual Studio 2019 创建 sln 工程使用 C++ SDK
本章节针对非CMake用户介绍如何在Visual Studio 2019 中创建 sln 工程使用 FastDeploy C++ SDK. CMake用户请直接看下一章节。另外本章节内容特别感谢“梦醒南天”同学关于FastDeploy使用的文档教程[如何在 Windows 上使用 FastDeploy C++ 部署 PaddleDetection 目标检测模型](https://www.bilibili.com/read/cv18807232) 本章节针对非CMake用户介绍如何在Visual Studio 2019 中创建 sln 工程使用 FastDeploy C++ SDK. CMake用户请直接看下一章节。另外本章节内容特别感谢“梦醒南天”同学关于FastDeploy使用的文档教程[如何在 Windows 上使用 FastDeploy C++ 部署 PaddleDetection 目标检测模型](https://www.bilibili.com/read/cv18807232)
<div id="VisualStudio2019Sln"></div> <div id="VisualStudio2019Sln"></div>
### 5.1 步骤一Visual Studio 2019 创建 sln 工程项目 #### 3.2.1 步骤一Visual Studio 2019 创建 sln 工程项目
<div id="VisualStudio2019Sln1"></div> <div id="VisualStudio2019Sln1"></div>
@@ -99,7 +106,7 @@ infer_ppyoloe_demo.exe ppyoloe_crn_l_300e_coco 000000014439.jpg 2 # GPU + Tenso
![image](https://user-images.githubusercontent.com/31974251/192817382-643c8ca2-1f2a-412e-954e-576c22b4ea62.png) ![image](https://user-images.githubusercontent.com/31974251/192817382-643c8ca2-1f2a-412e-954e-576c22b4ea62.png)
### 5.2 步骤二从examples中拷贝infer_ppyoloe.cc的代码到工程 #### 3.2.2 步骤二从examples中拷贝infer_ppyoloe.cc的代码到工程
<div id="VisualStudio2019Sln2"></div> <div id="VisualStudio2019Sln2"></div>
@@ -110,13 +117,13 @@ fastdeploy-win-x64-gpu-0.2.1\examples\vision\detection\paddledetection\cpp
![image](https://user-images.githubusercontent.com/31974251/192818456-21ca846c-ab52-4001-96d2-77c8174bff6b.png) ![image](https://user-images.githubusercontent.com/31974251/192818456-21ca846c-ab52-4001-96d2-77c8174bff6b.png)
### 5.3 步骤三:将工程配置设置成"Release x64"配置 #### 3.2.3 步骤三:将工程配置设置成"Release x64"配置
<div id="VisualStudio2019Sln3"></div> <div id="VisualStudio2019Sln3"></div>
![image](https://user-images.githubusercontent.com/31974251/192818918-98d7a54c-4a60-4760-a3cb-ecacc38b7e7a.png) ![image](https://user-images.githubusercontent.com/31974251/192818918-98d7a54c-4a60-4760-a3cb-ecacc38b7e7a.png)
### 5.4 步骤四配置头文件include路径 #### 3.2.4 步骤四配置头文件include路径
<div id="VisualStudio2019Sln4"></div> <div id="VisualStudio2019Sln4"></div>
@@ -143,7 +150,7 @@ D:\qiuyanjun\fastdeploy_build\built\fastdeploy-win-x64-gpu-0.2.1\third_libs\inst
用户需要根据自己实际的sdk路径稍作修改。 用户需要根据自己实际的sdk路径稍作修改。
### 5.5 步骤五配置lib路径和添加库文件 #### 3.2.5 步骤五配置lib路径和添加库文件
<div id="VisualStudio2019Sln5"></div> <div id="VisualStudio2019Sln5"></div>
@@ -163,7 +170,7 @@ D:\qiuyanjun\fastdeploy_build\built\fastdeploy-win-x64-gpu-0.2.1\third_libs\inst
![image](https://user-images.githubusercontent.com/31974251/192826884-44fc84a1-c57a-45f1-8ee2-30b7eaa3dce9.png) ![image](https://user-images.githubusercontent.com/31974251/192826884-44fc84a1-c57a-45f1-8ee2-30b7eaa3dce9.png)
### 5.6 步骤六:编译工程并运行获取结果 #### 3.2.6 步骤六:编译工程并运行获取结果
<div id="VisualStudio2019Sln6"></div> <div id="VisualStudio2019Sln6"></div>
@@ -184,12 +191,12 @@ D:\qiuyanjun\fastdeploy_test\infer_ppyoloe\x64\Release\infer_ppyoloe.exe
![image](https://user-images.githubusercontent.com/31974251/192829545-3ea36bfc-9a54-492b-984b-2d5d39094d47.png) ![image](https://user-images.githubusercontent.com/31974251/192829545-3ea36bfc-9a54-492b-984b-2d5d39094d47.png)
## 6. SDK使用方式三Visual Studio 2019 创建 CMake 工程使用 C++ SDK ### 3.3 SDK使用方式三Visual Studio 2019 创建 CMake 工程使用 C++ SDK
<div id="VisualStudio2019"></div> <div id="VisualStudio2019"></div>
本章节针对CMake用户介绍如何在Visual Studio 2019 中创建 CMake 工程使用 FastDeploy C++ SDK. 本章节针对CMake用户介绍如何在Visual Studio 2019 中创建 CMake 工程使用 FastDeploy C++ SDK.
### 6.1 步骤一Visual Studio 2019 创建“CMake”工程项目 #### 3.3.1 步骤一Visual Studio 2019 创建“CMake”工程项目
<div id="VisualStudio20191"></div> <div id="VisualStudio20191"></div>
@@ -206,7 +213,7 @@ D:\qiuyanjun\fastdeploy_test\infer_ppyoloe\x64\Release\infer_ppyoloe.exe
![image](https://user-images.githubusercontent.com/31974251/192143930-db1655c2-66ee-448c-82cb-0103ca1ca2a0.png) ![image](https://user-images.githubusercontent.com/31974251/192143930-db1655c2-66ee-448c-82cb-0103ca1ca2a0.png)
### 6.2 步骤二在CMakeLists中配置 FastDeploy C++ SDK #### 3.3.2 步骤二在CMakeLists中配置 FastDeploy C++ SDK
<div id="VisualStudio20192"></div> <div id="VisualStudio20192"></div>
@@ -246,7 +253,7 @@ install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release)
``` ```
注意,`install_fastdeploy_libraries`函数仅在最新的代码编译的SDK或版本>0.2.1下有效。 注意,`install_fastdeploy_libraries`函数仅在最新的代码编译的SDK或版本>0.2.1下有效。
### 6.3 步骤三生成工程缓存并修改CMakeSetting.json配置 #### 3.3.3 步骤三生成工程缓存并修改CMakeSetting.json配置
<div id="VisualStudio20193"></div> <div id="VisualStudio20193"></div>
@@ -277,7 +284,7 @@ install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release)
![image](https://user-images.githubusercontent.com/31974251/192146239-a1eacd9e-034d-4373-a262-65b18ce25b87.png) ![image](https://user-images.githubusercontent.com/31974251/192146239-a1eacd9e-034d-4373-a262-65b18ce25b87.png)
### 6.4 步骤四:生成可执行文件,运行获取结果。 #### 3.3.4 步骤四:生成可执行文件,运行获取结果。
<div id="VisualStudio20194"></div> <div id="VisualStudio20194"></div>
@@ -319,20 +326,116 @@ Visualized result saved in ./vis_result.jpg
特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps) 特别说明exe运行时所需要的依赖库配置方法请参考章节: [多种方法配置exe运行时所需的依赖库](#CommandLineDeps)
## 7. 多种方法配置exe运行时所需的依赖库 ## 4. 多种方法配置exe运行时所需的依赖库
<div id="CommandLineDeps"></div> <div id="CommandLineDeps"></div>
说明对于使用的最新源码编译的SDK或SDK版本>0.2.1的用户我们推荐使用4.14.2中的方式配置运行时的依赖库。如果使用的SDK版本<=0.2.1请参考4.34.4)中的方式进行配置。
### 7.1 方式一:修改CMakeLists.txt一行命令配置(推荐) ### 4.1 方式一:使用 fastdeploy_init.bat 进行配置推荐
<div id="CommandLineDeps1"></div> <div id="CommandLineDeps1"></div>
对于版本高于0.2.1的SDK我们提供了 **fastdeploy_init.bat** 工具来管理FastDeploy中所有的依赖库。可以通过该脚本工具查看(show)、拷贝(install) 和 设置(init and setup) SDK中所有的dll方便用户快速完成运行时环境配置。
#### 4.1.1 fastdeploy_init.bat 使用说明
<div id="CommandLineDeps11"></div>
首先进入SDK的根目录运行以下命令可以查看 fastdeploy_init.bat 的用法说明
```bat
D:\path-to-your-fastdeploy-sdk-dir>fastdeploy_init.bat help
------------------------------------------------------------------------------------------------------------------------------------------------------------
[1] [help] print help information: fastdeploy_init.bat help
[2] [show] show all dlls/libs/include paths: fastdeploy_init.bat show fastdeploy-sdk-dir
[3] [init] init all dlls paths for current terminal: fastdeploy_init.bat init fastdeploy-sdk-dir [WARNING: need copy onnxruntime.dll manually]
[4] [setup] setup path env for current terminal: fastdeploy_init.bat setup fastdeploy-sdk-dir [WARNING: need copy onnxruntime.dll manually]
[5] [install] install all dlls to a specific dir: fastdeploy_init.bat install fastdeploy-sdk-dir another-dir-to-install-dlls **[RECOMMEND]**
[6] [install] install all dlls with logging infos: fastdeploy_init.bat install fastdeploy-sdk-dir another-dir-to-install-dlls info
------------------------------------------------------------------------------------------------------------------------------------------------------------
```
用法简要说明如下:
- help: 打印所有的用法说明
- show: 查看SDK中所有的 dll、lib 和 include 路径
- init: 初始化所有dll路径信息后续用于设置terminal环境变量不推荐请参考4.3中关于onnxruntime的说明
- setup: 在init之后运行设置terminal环境便令不推荐请参考4.3中关于onnxruntime的说明
- install: 将SDK中所有的dll安装到某个指定的目录推荐
#### 4.1.2 fastdeploy_init.bat 查看 SDK 中所有的 dll、lib 和 include 路径
<div id="CommandLineDeps12"></div>
进入SDK的根目录运行show命令可以查看SDK中所有的 dll、lib 和 include 路径。以下命令中 %cd% 表示当前目录SDK的根目录
```bat
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat show %cd%
------------------------------------------------------------------------------------------------------------------------------------------------------------
[SDK] D:\path-to-fastdeploy-sdk-dir
------------------------------------------------------------------------------------------------------------------------------------------------------------
[DLL] D:\path-to-fastdeploy-sdk-dir\lib\fastdeploy.dll **[NEEDED]**
[DLL] D:\path-to-fastdeploy-sdk-dir\third_libs\install\faster_tokenizer\lib\core_tokenizers.dll **[NEEDED]**
[DLL] D:\path-to-fastdeploy-sdk-dir\third_libs\install\opencv\build\x64\vc15\bin\opencv_ffmpeg3416_64.dll **[NEEDED]**
......
------------------------------------------------------------------------------------------------------------------------------------------------------------
[Lib] D:\path-to-fastdeploy-sdk-dir\lib\fastdeploy.lib **[NEEDED][fastdeploy]**
[Lib] D:\path-to-fastdeploy-sdk-dir\third_libs\install\faster_tokenizer\lib\core_tokenizers.lib **[NEEDED][fastdeploy::text]**
[Lib] D:\path-to-fastdeploy-sdk-dir\third_libs\install\opencv\build\x64\vc15\lib\opencv_world3416.lib **[NEEDED][fastdeploy::vision]**
......
------------------------------------------------------------------------------------------------------------------------------------------------------------
[Include] D:\path-to-fastdeploy-sdk-dir\include **[NEEDED][fastdeploy]**
[Include] D:\path-to-fastdeploy-sdk-dir\third_libs\install\faster_tokenizer\include **[NEEDED][fastdeploy::text]**
[Include] D:\path-to-fastdeploy-sdk-dir\third_libs\install\opencv\build\include **[NEEDED][fastdeploy::vision]**
......
------------------------------------------------------------------------------------------------------------------------------------------------------------
[XML] D:\path-to-fastdeploy-sdk-dir\third_libs\install\openvino\runtime\bin\plugins.xml **[NEEDED]**
------------------------------------------------------------------------------------------------------------------------------------------------------------
```
可以看到该命令会根据您当前的SDK输出对应的信息包含 dll、lib 和 include 的路径信息。对于 dll被标记为 `[NEEDED]`的是运行时所需要的如果包含OpenVINO后端还需要将他的plugins.xml拷贝到exe所在的目录对于 lib 和 include被标记为`[NEEDED]`的是开发时所需要配置的最小依赖。并且我们还增加了对应的API Tag标记如果您只使用vision API则只需要配置标记为 `[NEEDED][fastdeploy::vision]` 的 lib 和 include 路径.
#### 4.1.3 fastdeploy_init.bat 安装 SDK 中所有的 dll 到指定的目录 (推荐)
<div id="CommandLineDeps13"></div>
进入SDK的根目录运行install命令可以将SDK 中所有的 dll 安装到指定的目录如exe所在的目录。我们推荐这种方式来配置exe运行所需要的依赖库。比如可以在SDK根目录下创建一个临时的bin目录备份所有的dll文件。以下命令中 %cd% 表示当前目录SDK的根目录
```bat
% info参数为可选参数添加info参数后会打印详细的安装信息 %
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat install %cd% bin
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat install %cd% bin info
```
```bat
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat install %cd% bin
[INFO] Do you want to install all FastDeploy dlls ?
[INFO] From: D:\path-to-fastdeploy-sdk-dir
[INFO] To: bin
Choose y means YES, n means NO: [y/n]y
YES.
请按任意键继续. . .
[INFO] Created bin done!
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
.....
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
已复制 1 个文件。
.....
```
#### 4.1.4 fastdeploy_init.bat 配置 SDK 环境变量
<div id="CommandLineDeps14"></div>
您也可以选择通过配置环境变量的方式来设置运行时的依赖库环境这种方式只在当前的terminal有效。如果您使用的SDK中包含了onnxruntime推理后端我们不推荐这种方式详细原因请参考4.3中关于onnxruntime配置的说明需要手动拷贝onnxruntime所有的dll到exe所在的目录。配置 SDK 环境变量的方式如下。以下命令中 %cd% 表示当前目录SDK的根目录
```bat
% 先运行 init 初始化当前SDK所有的dll文件路径 %
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat init %cd%
% 再运行 setup 完成 SDK 环境变量配置 %
D:\path-to-fastdeploy-sdk-dir>fastdeploy_init.bat setup %cd%
```
### 4.2 方式二修改CMakeLists.txt一行命令配置推荐
<div id="CommandLineDeps2"></div>
考虑到Windows下C++开发的特殊性如经常需要拷贝所有的lib或dll文件到某个指定的目录FastDeploy提供了`install_fastdeploy_libraries`的cmake函数方便用户快速配置所有的dll。修改ppyoloe的CMakeLists.txt添加 考虑到Windows下C++开发的特殊性如经常需要拷贝所有的lib或dll文件到某个指定的目录FastDeploy提供了`install_fastdeploy_libraries`的cmake函数方便用户快速配置所有的dll。修改ppyoloe的CMakeLists.txt添加
```cmake ```cmake
install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release) install_fastdeploy_libraries(${CMAKE_CURRENT_BINARY_DIR}/Release)
``` ```
注意该方式仅在最新的代码编译的SDK或版本>0.2.1下有效。 注意该方式仅在最新的代码编译的SDK或版本>0.2.1下有效。
### 7.2 方式:命令行设置环境变量 ### 4.3 方式:命令行设置环境变量
<div id="CommandLineDeps2"></div> <div id="CommandLineDeps3"></div>
编译好的exe保存在Release目录下在运行demo前需要将模型和测试图片拷贝至该目录。另外需要在终端指定DLL的搜索路径。请在build目录下执行以下命令。 编译好的exe保存在Release目录下在运行demo前需要将模型和测试图片拷贝至该目录。另外需要在终端指定DLL的搜索路径。请在build目录下执行以下命令。
```bat ```bat
@@ -371,9 +474,9 @@ set PATH=%FASTDEPLOY_HOME%\third_libs\install\openvino\runtime\3rdparty\tbb\bin;
setup_fastdeploy_dll.bat setup_fastdeploy_dll.bat
``` ```
### 7.3 方式手动拷贝依赖库到exe的目录下 ### 4.4 方式手动拷贝依赖库到exe的目录下
<div id="CommandLineDeps3"></div> <div id="CommandLineDeps4"></div>
手动拷贝或者在build目录下执行以下命令 手动拷贝或者在build目录下执行以下命令
```bat ```bat
@@ -404,10 +507,3 @@ copy /Y %FASTDEPLOY_HOME%\third_libs\install\openvino\runtime\3rdparty\tbb\bin\*
copy_fastdeploy_dll.bat copy_fastdeploy_dll.bat
``` ```
特别说明上述的set和copy命令对应的依赖库路径需要用户根据自己使用SDK中的依赖库进行适当地修改。比如若是CPU版本的SDK则不需要TensorRT相关的设置。 特别说明上述的set和copy命令对应的依赖库路径需要用户根据自己使用SDK中的依赖库进行适当地修改。比如若是CPU版本的SDK则不需要TensorRT相关的设置。
## 8. CLion 2022 IDE 方式使用 C++ SDK
<div id="CLion"></div>
- TODO

167
scripts/fastdeploy_init.bat Normal file
View File

@@ -0,0 +1,167 @@
@echo off
set __script_action_type=%1
set __fastdeploy_sdk_dir=%2
set __another_target_dir=%3
set __install_infos_flag=%4
@rem help
if "%__script_action_type%" == "help" (
call:__print_long_line
echo [1] [help] print help information: fastdeploy_init.bat help
echo [2] [show] show all dlls/libs/include paths: fastdeploy_init.bat show fastdeploy-sdk-dir
echo [3] [init] init all dlls paths for current terminal: fastdeploy_init.bat init fastdeploy-sdk-dir [WARNING: need copy onnxruntime.dll manually]
echo [4] [setup] setup path env for current terminal: fastdeploy_init.bat setup fastdeploy-sdk-dir [WARNING: need copy onnxruntime.dll manually]
echo [5] [install] install all dlls to a specific dir: fastdeploy_init.bat install fastdeploy-sdk-dir another-dir-to-install-dlls **[RECOMMEND]**
echo [6] [install] install all dlls with logging infos: fastdeploy_init.bat install fastdeploy-sdk-dir another-dir-to-install-dlls info
call:__print_long_line
goto:eof
)
@rem show dlls and libs
if "%__script_action_type%" == "show" (
call:__print_long_line
echo [SDK] %__fastdeploy_sdk_dir%
call:__print_long_line
set __have_openvino_flag=false
set __fastdeploy_lib_dir=%__fastdeploy_sdk_dir%\lib
@setlocal enabledelayedexpansion
echo [DLL] !__fastdeploy_lib_dir!\fastdeploy.dll **[NEEDED]**
for /f "delims= " %%a in ('dir /s /b %__fastdeploy_sdk_dir%\third_libs ^| findstr /e \.dll ^| findstr /v "vc14\\bin\\opencv"') do (
set __3rd_dll_file=%%a && set __3rd_needed_flag=true
echo !__3rd_dll_file! | findstr "openvino">nul && set __have_openvino_flag=true
echo !__3rd_dll_file! | findstr d\.dll>nul && set __3rd_needed_flag=false
if "!__3rd_needed_flag!"=="false" (echo !__3rd_dll_file! | findstr /v opencv>nul && set __3rd_needed_flag=true)
echo !__3rd_dll_file! | findstr debug\.dll>nul && set __3rd_needed_flag=false
if "!__3rd_needed_flag!"=="true" (echo [DLL] !__3rd_dll_file! **[NEEDED]**) else (echo [DLL] !__3rd_dll_file!)
)
call:__print_long_line
echo [Lib] !__fastdeploy_lib_dir!\fastdeploy.lib **[NEEDED][fastdeploy]**
for /f "delims= " %%a in ('dir /s /b %__fastdeploy_sdk_dir%\third_libs ^| findstr /e \.lib ^| findstr /v "vc14\\lib\\opencv"') do (
set __3rd_lib_file=%%a && set __3rd_needed_flag=false && set __api_tag=fastdeploy
echo !__3rd_lib_file! | findstr "opencv">nul && set __3rd_needed_flag=true
echo !__3rd_lib_file! | findstr "opencv">nul && set __api_tag=!__api_tag!::vision
if "!__3rd_needed_flag!"=="true" (echo !__3rd_lib_file! | findstr d\.lib>nul && set __3rd_needed_flag=false)
echo !__3rd_lib_file! | findstr "faster_tokenizer">nul && set __3rd_needed_flag=true
echo !__3rd_lib_file! | findstr "faster_tokenizer">nul && set __api_tag=!__api_tag!::text
if "!__3rd_needed_flag!"=="true" (echo [Lib] !__3rd_lib_file! **[NEEDED][!__api_tag!]**) else (echo [Lib] !__3rd_lib_file!)
)
call:__print_long_line
set __fastdeploy_include_dir=%__fastdeploy_sdk_dir%\include
echo [Include] !__fastdeploy_include_dir! **[NEEDED][fastdeploy]**
for /f "delims= " %%a in ('dir /s /b %__fastdeploy_sdk_dir%\third_libs ^| findstr /e include ^| findstr /v "vc14\\bin\\opencv"') do (
set __3rd_include_dir=%%a && set __3rd_needed_flag=false && set __api_tag=fastdeploy
echo !__3rd_include_dir! | findstr "opencv">nul && set __3rd_needed_flag=true
echo !__3rd_include_dir! | findstr "opencv">nul && set __api_tag=!__api_tag!::vision
echo !__3rd_include_dir! | findstr "faster_tokenizer">nul && set __3rd_needed_flag=true
echo !__3rd_include_dir! | findstr "faster_tokenizer">nul && set __api_tag=!__api_tag!::text
if "!__3rd_needed_flag!"=="true" (echo [Include] !__3rd_include_dir! **[NEEDED][!__api_tag!]**) else (echo [Include] !__3rd_include_dir!)
)
call:__print_long_line
if "!__have_openvino_flag!"=="true" (
for /f "delims= " %%a in ('dir /s /b %__fastdeploy_sdk_dir%\third_libs ^| findstr /e \.xml ^| findstr "openvino"') do (
set __openvino_plugin_xml=%%a
echo [XML] !__openvino_plugin_xml! **[NEEDED]**
)
call:__print_long_line
)
@setlocal disabledelayedexpansion
goto:eof
)
@rem init all paths for dlls
if "%__script_action_type%" == "init" (
@setlocal enabledelayedexpansion
set /p yes_or_no=Init dll paths for FastDeploy in current terminal: [y/n]
if "!yes_or_no!"=="y" (echo YES.) else (echo NO. && pause && goto:eof)
@setlocal disabledelayedexpansion
if exist bin.txt (del /Q bin.txt)
if exist lib.txt (del /Q lib.txt)
for /f "delims= " %%a in ('dir /s /b /A:D %__fastdeploy_sdk_dir% ^| findstr /v include ^| findstr /e bin ^| findstr /v "vc14\\bin"') do (>>bin.txt set /p=%%a;<nul)
for /f "delims= " %%a in ('dir /s /b /A:D %__fastdeploy_sdk_dir% ^| findstr /v include ^| findstr /e lib ^| findstr /v "vc14\\lib"') do (>>lib.txt set /p=%%a;<nul)
for /f %%i in (bin.txt) do (endlocal & set __fastdeploy_bin_paths=%%i)
for /f %%j in (lib.txt) do (endlocal & set __fastdeploy_lib_paths=%%j)
pause
call:__print_long_line
echo [INFO] FastDeploy dlls paths init done! Please run: [fastdeploy_init.bat setup fastdeploy-sdk-dir]
echo [INFO] command to push these dlls paths into PATH ENV in current terminal.
call:__print_long_line
goto:eof
)
@rem setup PATH ENV for all dlls
if "%__script_action_type%" == "setup" (
@setlocal enabledelayedexpansion
set /p yes_or_no=Setup PATH ENV for FastDeploy in current terminal: [y/n]
if "!yes_or_no!"=="y" (echo YES.) else (echo NO. && pause && goto:eof)
@setlocal disabledelayedexpansion
if not exist bin.txt (echo Can not found bin.txt, Please run init before setup && goto:eof)
if not exist lib.txt (echo Can not found lib.txt, Please run init before setup && goto:eof)
for /f %%i in (bin.txt) do (endlocal & set __fastdeploy_bin_paths=%%i)
for /f %%j in (lib.txt) do (endlocal & set __fastdeploy_lib_paths=%%j)
set "PATH=%__fastdeploy_bin_paths%%__fastdeploy_lib_paths%%PATH%"
pause
call:__print_long_line
echo [INFO] FastDeploy PATH ENV setup done! Please use [set PATH] to check PATH ENV in current terminal.
echo [INFO] Just setup once again if the paths of FastDeploy can not be found in your PATH ENV.
call:__print_long_line
echo [WARN] Please copy all onnxruntime dlls manually to your-exe-or-custom-dll-dir if ENABLE_ORT_BACKEND=ON.
echo [WARN] Use [fastdeploy_init.bat show fastdeploy-sdk-dir] to find the dll's location of onnxruntime.
call:__print_long_line
goto:eof
)
@rem copy all dlls to a specific location
if "%__script_action_type%" == "install" (
@setlocal enabledelayedexpansion
if "!__install_infos_flag!"=="noconfirm" (
echo [INFO] Installing all FastDeploy dlls ...
) else (
echo [INFO] Do you want to install all FastDeploy dlls ?
echo [INFO] From: !__fastdeploy_sdk_dir!
echo [INFO] To: !__another_target_dir!
set /p yes_or_no=Choose y means YES, n means NO: [y/n]
if "!yes_or_no!"=="y" (echo YES.) else (echo NO. && pause && goto:eof)
pause
)
@setlocal disabledelayedexpansion
if not exist %__fastdeploy_sdk_dir% ( echo [ERROR] %__fastdeploy_sdk_dir% is not exist ! && goto:eof )
if not exist %__another_target_dir% ( mkdir %__another_target_dir% && echo [INFO] Created %__another_target_dir% done!)
set __have_openvino_flag=false
@setlocal enabledelayedexpansion
for /f "delims= " %%a in ('dir /s /b %__fastdeploy_sdk_dir% ^| findstr /e \.dll ^| findstr /v "vc14\\bin\\opencv"') do (
set __3rd_or_fd_dll_file=%%a && set __3rd_or_fd_needed_flag=true
echo !__3rd_or_fd_dll_file! | findstr "openvino">nul && set __have_openvino_flag=true
echo !__3rd_or_fd_dll_file! | findstr d\.dll>nul && set __3rd_or_fd_needed_flag=false
if "!__3rd_or_fd_needed_flag!"=="false" ( echo !__3rd_or_fd_dll_file! | findstr /v opencv>nul && set __3rd_or_fd_needed_flag=true)
echo !__3rd_or_fd_dll_file! | findstr debug\.dll>nul && set __3rd_or_fd_needed_flag=false
if "!__3rd_or_fd_needed_flag!"=="true" (
copy /Y !__3rd_or_fd_dll_file! %__another_target_dir%
if "!__install_infos_flag!"=="info" ( echo [Installed][DLL] !__3rd_or_fd_dll_file! "--->" %__another_target_dir%)
)
)
if "!__have_openvino_flag!"=="true" (
for /f "delims= " %%a in ('dir /s /b %__fastdeploy_sdk_dir% ^| findstr /e \.xml ^| findstr "openvino"') do (
set __openvino_plugin_xml=%%a
copy /Y !__openvino_plugin_xml! %__another_target_dir%
if "!__install_infos_flag!"=="info" ( echo [Installed][XML] !__openvino_plugin_xml! "--->" %__another_target_dir% )
)
)
@setlocal disabledelayedexpansion
goto:eof
)
goto:eof
@rem helpers
:__print_long_line
echo ------------------------------------------------------------------------------------------------------------------------------------------------------------
goto:eof
@rem end
@echo on