本來繼上集(【芒果派MangoPi MQ Quad】利用MangoPi MQ Quad部署一個網絡攝像頭-電子發燒友網 (elecfans.com))后,繼續寫公網視頻傳輸,后來一直沒找到合適的公網穿透工具,找了幾個要么不免費,要么各種驗證,還是放棄吧。
得益于四核A53的性能,NCNN跑起來應該問題不大,本文主要介紹NCNN在MangoPi MQ Quad上的部署和測試。
一、NCNN介紹
ncnn 是一個為手機端極致優化的高性能神經網絡前向計算框架。 ncnn 從設計之初深刻考慮手機端的部署和使用。 無第三方依賴,跨平臺,手機端 cpu 的速度快于目前所有已知的開源框架。 基于 ncnn,開發者能夠將深度學習算法輕松移植到手機端高效執行, 開發出人工智能 APP,將 AI 帶到你的指尖。 ncnn 目前已在騰訊多款應用中使用,如:QQ,Qzone,微信,天天 P 圖等。
ncnn: ncnn ncnn 是騰訊優圖實驗室首個開源項目,是一個為手機端極致優化的高性能神經網絡前向計算框架 (gitee.com)
二、源碼下載&編譯
(一)源碼下載
NCNN的github(github.com/Tencent/ncnn)拉源碼。
root@orangepizero2:~# git clone https://github.com/Tencent/ncnn.git Cloning into 'ncnn'... remote: Enumerating objects: 31640, done. remote: Counting objects: 100% (5982/5982), done. remote: Compressing objects: 100% (498/498), done. remote: Total 31640 (delta 5754), reused 5489 (delta 5484), pack-reused 25658 Receiving objects: 100% (31640/31640), 22.19 MiB | 2.33 MiB/s, done. Resolving deltas: 100% (26851/26851), done. Updating files: 100% (3195/3195), done.
(二)源碼編譯
考慮到四核A53的能力,加上NCNN本身也支持板上直接編譯,所以就不去PC上搞交叉編譯了。
Debian包自帶gcc,所以就不需要在MangoPi MQ Quad編譯安裝了,頂多更新下。
按照下面順序:
cd ?ncnn-root-dir??> mkdir -p build-aarch64-linux-gnu cd build-aarch64-linux-gnu cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-linux-gnu.toolchain.cmake .. make -j$(nproc)
操作及log如下:
root@orangepizero2:~/ncnn/build-aarch64-linux-gnu# cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-linux-gnu.toolchain.cmake .. -- CMAKE_TOOLCHAIN_FILE = /root/ncnn/toolchains/aarch64-linux-gnu.toolchain.cmake -- CMAKE_INSTALL_PREFIX = /root/ncnn/build-aarch64-linux-gnu/install -- NCNN_VERSION_STRING = 1.0.20230721 -- The C compiler identification is GNU 10.2.1 -- The CXX compiler identification is GNU 10.2.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test NCNN_COMPILER_SUPPORT_GNU_INLINE_ASM -- Performing Test NCNN_COMPILER_SUPPORT_GNU_INLINE_ASM - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM_VFPV4 -- Performing Test NCNN_COMPILER_SUPPORT_ARM_VFPV4 - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM82_FP16 -- Performing Test NCNN_COMPILER_SUPPORT_ARM82_FP16 - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM82_DOTPROD -- Performing Test NCNN_COMPILER_SUPPORT_ARM82_DOTPROD - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM82_FP16FML -- Performing Test NCNN_COMPILER_SUPPORT_ARM82_FP16FML - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM84_BF16 -- Performing Test NCNN_COMPILER_SUPPORT_ARM84_BF16 - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM84_I8MM -- Performing Test NCNN_COMPILER_SUPPORT_ARM84_I8MM - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVE -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVE - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVE2 -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVE2 - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVEBF16 -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVEBF16 - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVEI8MM -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVEI8MM - Success -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVEF32MM -- Performing Test NCNN_COMPILER_SUPPORT_ARM86_SVEF32MM - Success -- Target arch: arm 64bit -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY -- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY -- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success -- Performing Test COMPILER_HAS_DEPRECATED_ATTR -- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success -- Found OpenMP_C: -fopenmp (found version "4.5") -- Found OpenMP_CXX: -fopenmp (found version "4.5") -- Found OpenMP: TRUE (found version "4.5") -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - yes -- Found Threads: TRUE -- Configuring done -- Generating done -- Build files have been written to: /root/ncnn/build-aarch64-linux-gnu root@orangepizero2:~/ncnn/build-aarch64-linux-gnu# make -j4 Scanning dependencies of target ncnn-generate-spirv [ 0%] Built target ncnn-generate-spirv Scanning dependencies of target ncnn [ 1%] Building CXX object src/CMakeFiles/ncnn.dir/benchmark.cpp.o [ 1%] Building CXX object src/CMakeFiles/ncnn.dir/allocator.cpp.o [ 2%] Building CXX object src/CMakeFiles/ncnn.dir/blob.cpp.o [ 2%] Building CXX object src/CMakeFiles/ncnn.dir/c_api.cpp.o [ 3%] Building CXX object src/CMakeFiles/ncnn.dir/command.cpp.o [ 3%] Building CXX object src/CMakeFiles/ncnn.dir/cpu.cpp.o [ 4%] Building CXX object src/CMakeFiles/ncnn.dir/datareader.cpp.o [ 4%] Building CXX object src/CMakeFiles/ncnn.dir/gpu.cpp.o [ 5%] Building CXX object src/CMakeFiles/ncnn.dir/layer.cpp.o [ 5%] Building CXX object src/CMakeFiles/ncnn.dir/mat.cpp.o .... [ 99%] Building CXX object src/CMakeFiles/ncnn.dir/layer/copyto.cpp.o [100%] Linking CXX static library libncnn.a [100%] Built target ncnn Scanning dependencies of target benchncnn [100%] Building CXX object benchmark/CMakeFiles/benchncnn.dir/benchncnn.cpp.o [100%] Linking CXX executable benchncnn [100%] Built target benchncnn root@orangepizero2:~/ncnn/build-aarch64-linux-gnu# ll total 56 drwxr-xr-x 3 root root 4096 Jul 21 15:36 benchmark -rw-r--r-- 1 root root 28856 Jul 21 15:19 CMakeCache.txt drwxr-xr-x 5 root root 4096 Jul 21 15:36 CMakeFiles -rw-r--r-- 1 root root 1917 Jul 21 15:19 cmake_install.cmake -rw-r--r-- 1 root root 7466 Jul 21 15:19 Makefile drwxr-xr-x 3 root root 4096 Jul 21 15:35 src
等了大約10分鐘,畢竟編譯速度比不上X86,檢查下生成的可執行文件,正常:
root@orangepizero2:~/ncnn/build-aarch64-linux-gnu# file benchmark/benchncnn benchmark/benchncnn: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1,x 3.7.0, not stripped
三、測試
將生成的可執行文件拷貝到原目錄的benchmark/文件夾中,因為這里面有測試需要的模型數據。
root@orangepizero2:~/ncnn/build-aarch64-linux-gnu/benchmark# cd ../../benchmark/ root@orangepizero2:~/ncnn/benchmark# ls alexnet.param efficientnet_b0.param mnasnet.param mobilenet_v2.param proxylessnasnet.param resnet50_int8.param sq benchncnn efficientnetv2_b0.param mobilenet_int8.param mobilenetv2_yolov3.param README.md resnet50.param sq benchncnn.cpp FastestDet.param mobilenet.param mobilenet_v3.param regnety_400m.param shufflenet.param sq blazeface.param googlenet_int8.param mobilenet_ssd_int8.param mobilenet_yolo.param resnet18_int8.param shufflenet_v2.param vg CMakeLists.txt googlenet.param mobilenet_ssd.param nanodet_m.param resnet18.param squeezenet_int8.param vg
執行一下,幾個模型測試都跑個遍:
責任編輯:彭菁
-
攝像頭
+關注
關注
60文章
4856瀏覽量
95990 -
開源
+關注
關注
3文章
3381瀏覽量
42604
發布評論請先 登錄
相關推薦
評論