当前位置:网站首页>Paddlelite compilation and code running through the disk
Paddlelite compilation and code running through the disk
2022-07-29 10:59:00 【Master Fuwen】
I am a tm Big enemy species of , notice Paddle lite Just be afraid
Sometimes run Paddle Lite If the code is wrong , stay spyder Give it directly to me inside restart kernel, I tm…
The basic operation is based on this document :
https://paddle-lite.readthedocs.io/zh/develop/source_compile/windows_compile_windows.html
(PaddleLite The update speed of is faster , Pay attention to timeliness )
1. git Basic operation problems of
I met all kinds of git Basic operation problems of :
- The success of
ping github.com,ping Change if it doesn't work host file ( Don't dwell on ) - git Throughout clone Not coming down , Use an acceleration channel
https://github.91chi.fun/, A kind of , Previoushub.fastgit.orgHang up - Then is third-party The directory should include third-party github package clone Come down , Recursive modification
.gitmoduleand.git/configfile , Until you execute the commandgit submodule update --init --recursiveNo problem
Add here , Current version Paddle Lite Windows Compiled scripts lite\tools\build_windows.bat
Yes bug, His own document says , hold third-party Delete the table of contents , The script will be downloaded automatically third-party, However, there are actually problems

Look at him batch Script , Download directly from this link :
https://paddlelite-data.bj.bcebos.com/third_party_libs/third-party-91a9ab3.tar.gz
2. Compile start :
I met VS2019 There is a problem with the compilation , So I downloaded VS2015
About VS2015 Installation , You can refer to here :
https://blog.csdn.net/HaoZiHuang/article/details/126020139
Then directly compile :
lite\tools\build_windows.bat with_extra with_profile with_precision_profile

10000+ Multiple warning…
There are some episodes in the middle :
CMake Error at lite/kernels/CMakeLists.txt:118 (message):
Traceback (most recent call last):
File "xxxxx/Paddle-Lite/lite/tools/cmake_tools/create_fake_kernel_registry.py", line 243, in <module>
parse_fake_kernels_from_path(faked_kernels_list_path)
File "xxxxx/Paddle-Lite/lite/tools/cmake_tools/create_fake_kernel_registry.py", line 101, in parse_fake_kernels_from_path
paths = set([path for path in f])
File "xxxxx/Paddle-Lite/lite/tools/cmake_tools/create_fake_kernel_registry.py", line 101, in <listcomp>
paths = set([path for path in f])
UnicodeDecodeError: 'gbk' codec can't decode byte 0x95 in position 37:
illegal multibyte sequence
-- Configuring incomplete, errors occurred!
See also "xxxxx/Paddle-Lite/build.lite.x86/CMakeFiles/CMakeOutput.log".
See also "xxxxx/Paddle-Lite/build.lite.x86/CMakeFiles/CMakeError.log".
Need to give the upper open Add encoding='utf-8', To the authorities PR, I don't know whether it will be merged :
https://github.com/PaddlePaddle/Paddle-Lite/pull/9301
If you use VS2019 perhaps VS2017 compile , Then use use_vs2017 and use_vs2019 Specify the parameter , Do not add these two parameters , It's the default VS2015 compile , If your installation location changes or there is no installation , He will let you fill in the path manually , If you fill in VS2019 perhaps VS2017 The path of , This command line exits directly … There is no hint
For specific parameters of compilation, please refer to :
https://paddle-lite.readthedocs.io/zh/develop/source_compile/windows_compile_windows.html

3. Precompiled translation package
You can download the precompiled package from here , But there is no such thing as Py3.8 And the versions above :
https://paddle-lite.readthedocs.io/zh/latest/quick_start/release_lib.html#windows

About the meaning of each compiled file , The following references are from here :
https://paddle-lite.readthedocs.io/zh/develop/source_compile/windows_compile_windows.html#id14
The compilation result is located in build.lite.x86\inference_lite_lib
The details are as follows :
cxxFolder : contain c++ Library file and corresponding header fileinclude: The header filelib: The library files
Static library files :libpaddle_api_full_bundled.lib:full_api Static librarylibpaddle_api_light_bundled.lib:light_api Static librarythird_partyFolder : Dependent third-party prediction Library mklml
mklml : Paddle Lite The prediction library depends on mklml Math librarydemo\cxxFolder :C++ Example demomobilenetv1_full: Use full_api perform mobilenet_v1 Predicted C++ demomobilenetv1_light: Use light_api perform mobilenet_v1 Predicted C++ demodemo\python: Python Example demomobilenetv1_full_api.py: Use full_api perform mobilenet_v1 Predicted Python demomobilenetv1_light_api.py: Use full_api perform mobilenet_v1 Predicted Python demopythonFolder : contain Python Library file and corresponding .whl packageinstallFolder : Compiled successfully .whl Package is located in theinstall\dist\*.whllibFolder :.whl Library files that the package depends on
actually , The result of compilation , The content is the same as that of this precompiled package
however , My compiled package cannot be used , stay github It was mentioned that issue:
https://github.com/PaddlePaddle/Paddle-Lite/issues/9298
4. pip Direct installation ( Suggest this …)
Due to the present py3.8 None of the above precompiled packages , So create a new one conda Environmental Science Python=3.7
then :
python -m pip install paddlelite==2.11
5. verification ( Conversion part )
PaddleLite You need to convert the static graph model into nb Format , stay linux The environment has opt Tools , stay windows Environmental Science , Script only :
import paddlelite.lite as lite
a = lite.Opt()
# Not combined form
# a.set_model_dir("mobilenet_v1")
# combined form , Specific model and parameter name , Please modify according to the actual situation
a.set_model_file("model.pdmodel")
a.set_param_file("model.pdiparams")
a.set_optimize_out("pplite")
a.set_valid_places("x86")
a.run()
It should be noted that
model.pdmodelFile with the__model__File corresponding to themodel.pdiparamsFile with the__param__File corresponding to the
in addition , There are two static graph models : Not combined form And combined form
The latter is the two above , The former is dark brown :
__model__ The file is the topology of the model , The other files are parameter files
The script above , Will generate a .nb file
6. verification ( The reasoning part )
Excerpt from PaddleLite file :
https://paddle-lite.readthedocs.io/zh/latest/api_reference/python_api_doc.html
from paddlelite.lite import *
import numpy as np
from PIL import Image
# (1) Setting configuration information
config = MobileConfig()
config.set_model_from_file("./mobilenet_v1_opt.nb")
# (2) Create predictors
predictor = create_paddle_predictor(config)
# (3) Read data from pictures
image = Image.open('./example.jpg')
resized_image = image.resize((224, 224), Image.BILINEAR)
image_data = np.array(resized_image).transpose(2, 0, 1).reshape(1, 3, 224, 224)
# (4) Set input data
input_tensor = predictor.get_input(0)
input_tensor.from_numpy(image_data)
# (5) Execution forecast
predictor.run()
# (6) Get the output data
output_tensor = predictor.get_output(0)
print(output_tensor.shape())
print(output_tensor.numpy())
Just run
边栏推荐
- IPV6基础
- Meeting OA project (V) -- meeting notice and feedback details
- Function comparison between report control FastReport and stimulus soft
- leetcode-位运算
- 幸运抽奖系统带后台源码
- ES6-箭头函数this指向
- StarRocks 技术内幕:实时更新与极速查询如何兼得
- 周鸿祎:360是世界上最大的安全大数据公司
- 开源峰会抢先看 | 7 月 29 日分论坛 & 活动议程速览
- The heavy | open atomic school source activity was officially launched
猜你喜欢
随机推荐
【图像检测】基于灰度图像的积累加权边缘检测方法研究附matlab代码
Ggdag draw DAG and cause and effect diagram
Alibaba architects spent a year sorting out the "Lucene advanced document", and you are also a big factory employee!
开源峰会抢先看 | 7 月 29 日分论坛 & 活动议程速览
How to start writing helm charts for your kubernetes application
Applied practical skills of deep reinforcement learning
LeetCode二叉树系列——144.二叉树的前序遍历
Zhou Hongyi: 360 is the largest secure big data company in the world
IPV6基础
从零开始Blazor Server(3)--添加cookie授权
Self collection online computer wallpaper PHP source code v2.0 adaptive end
1.MySQL数据库的介绍
深入理解C# 进入快速通道的委托
Package Delivery(贪心)
Learning R language these ebooks are enough!
Understand what a binary tree is (types, traversal methods, definitions of binary trees)
如何开始为您的 Kubernetes 应用程序编写 Helm 图表
The heavy | open atomic school source activity was officially launched
Spark efficient data analysis 02, basic knowledge 13
8.穿插-从架构设计到实践理解ThreadPoolExecutor线程池









