樹莓派4B安裝 百度飛槳paddlelite 做視頻檢測 (一、環境安裝)


前言:

當前准備重新在樹莓派4B8G 上面搭載訓練模型進行識別檢測,訓練采用了百度飛槳的PaddleX再也不用為訓練部署環境各種報錯發愁了,推薦大家使用。

關於在樹莓派4B上面paddlelite的文章很多,特別是 諾亞方包 還有 耐心的小黑    的教程給了我很多指導,再此對他們表示感謝。

這次將采用最新的包進行部署,希望能將全過程記錄下來跟大家做個分享

linux系統采用了官方最新的Raspberry Pi 64位系統   :Raspberry Pi OS with desktop

https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2022-01-28/2022-01-28-raspios-bullseye-arm64.zip 

  • Raspberry Pi OS with desktop

    • Release date: January 28th 2022
    • System: 64-bit
    • Kernel version: 5.10
    • Debian version: 11 (bullseye)
    • Size: 1,135MB

一、完成Linux 本地編譯環境的准備
安裝patchelf
sudo apt install patchelf

sudo apt-get install libssl-dev

更新一下目錄
sudo apt-get update

升級安裝
sudo apt-get install -y


安裝gcc g++
sudo apt-get install gcc g++


安裝cmake
wget https://github.com/Kitware/CMake/releases/download/v3.23.0-rc2/cmake-3.23.0-rc2.tar.gz
tar -zxvf cmake-3.23.0-rc2.tar.gz

配置
cd cmake-3.23.0-rc2
./configure

 

開始編譯:
make          

(漫長的等待...)

安裝:

sudo make install

查看cmake版本以驗證安裝成功:

cmake --version

二、源碼編譯

1. 下載Paddle-Lite 源碼(當前最新版本為V2.10)  注意:如果你的Terminal當前目錄還在 cmake目錄下請退到根目錄再進行下面的命令,最簡單的辦法就是關掉再重新打開一下,這樣可以避免下載完找不到目錄的錯誤!

 注意:如果不在GitHub下載,在git checkout release/v2.10 切換分支的時候要注意下載下來的文件名稱大小寫

git clone https://github.com/PaddlePaddle/Paddle-Lite.git

 

切換到發布分支

cd Paddle-Lite && git checkout release/v2.10

 

(可選) 刪除 third-party 目錄,編譯腳本會自動從國內 CDN 下載第三方庫文件

 rm -rf third-party

 

 

執行編譯腳本

./lite/tools/build_linux.sh --arch=armv7hf   --with_python=ON 


 ./lite/tools/build_linux.sh --arch=armv8  --with_python=ON

(參考:https://paddle-lite.readthedocs.io/zh/release-v2.10_a/source_compile/arm_linux_compile_arm_linux.html)

注意:

如果你使用官方教程執行編譯腳本

./lite/tools/build_linux.sh

估計你跟我最初一樣會報錯,耗費了很長時間才搞定,后面必須加參數:

 

Make Error at CMakeLists.txt:34 (project):
The CMAKE_CXX_COMPILER:

 

aarch64-linux-gnu-g++

 

is not a full path and was not found in the PATH.

 

Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.

 


CMake Error at CMakeLists.txt:34 (project):
The CMAKE_C_COMPILER:

 

aarch64-linux-gnu-gcc

 

is not a full path and was not found in the PATH.

 

Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

 

ok,經過上面的經驗你已經成功避過了一個坑,但是如果你的網絡環境不是國內外通殺的話,執行過程中會報以下錯誤

 

RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.

 

經過我不斷出坑如坑的血淚經驗,再傳授一招,來拯救你那脆弱的git速度:

修改下載方式-https改為ssh

git clone git://git.openwrt.org/feed/packages.git

修改feeds.conf.default配置

src-git packages git://git.openwrt.org/feed/packages.git
src-git luci https://git.openwrt.org/project/luci.git
src-git routing https://git.openwrt.org/feed/routing.git
src-git telephony https://git.openwrt.org/feed/telephony.git
#src-git video https://github.com/openwrt/video.git
#src-git targets https://github.com/openwrt/targets.git
#src-git management https://github.com/openwrt-management/packages.git
#src-git oldpackages http://git.openwrt.org/packages.git
#src-link custom /usr/src/openwrt/custom-feed

好了,現在可以重新再執行編譯腳本一遍:./lite/tools/build_linux.sh --arch=armv7hf --with_python=ON

配置好以后如果還是連不上,多重新幾次,親測有效,這個方法我覺的比修改dns管用。)

 

 

(漫長的編譯等待...)

三、安裝Paddle-Lite

inference_lite_lib.armlinux.armv7hf/
|-- cxx                                     C++ 預測庫和頭文件
|   |-- include                             C++ 頭文件
|   |   |-- paddle_api.h
|   |   |-- paddle_image_preprocess.h
|   |   |-- paddle_lite_factory_helper.h
|   |   |-- paddle_place.h
|   |   |-- paddle_use_kernels.h
|   |   |-- paddle_use_ops.h
|   |   `-- paddle_use_passes.h
|   `-- lib                                 C++預測庫
|       |-- libpaddle_api_light_bundled.a   C++靜態庫
|       `-- libpaddle_light_api_shared.so   C++動態庫
|
|-- demo                          
|   `-- python                              python預測庫demo
|
|-- python                                  Python預測庫(需要打開with_python選項)
|   |-- install
|   |   `-- dist
|   |       `-- paddlelite-*.whl            python whl包 
|   |-- lib
|       `-- lite.so                     

 

先進入paddlelite-*.whl文件目錄里:

 cd    build.lite.linux.armv7hf.gcc/inference_lite_lib.armlinux.armv7hf/python/install/dist

直接安裝 

pip3 install paddlelite-*.whl

 

安裝完成后驗證是否成功

進入python程序:

python

執行以下命令:

import paddlelite

import paddlelite.lite

 

第一階段總結:完成以上部署,系統環境部分就算是完成了,希望我們國家能夠放開對github的限制,研發人員人生苦短!同時也希望百度的技術人員能夠把官方手冊寫的更完善,不要學msdn!

            

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM