日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

Ubuntu 18.04 LTS环境下 MNN 的编译与使用

發布時間:2023/12/15 Ubuntu 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ubuntu 18.04 LTS环境下 MNN 的编译与使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

環境 Ubuntu 18.04 LTS

本文主要介紹從github上下載 MNN 后,如何快速的進行編譯

1.安裝C/C++編譯器 gcc 與 NDK

#首先安裝好gcc, 用來編譯 MNN 中的工具等內容
sudo apt install build-essential
gcc --version

#其次, 安裝NDK或者安裝Android Studio, 然后安裝NDK插件,
#在https://developer.android.com/ndk/downloads/下載安裝NDK,建議使用最新穩定版本
#NDK用來編譯Android版本的 libmnn.so

  • 安裝protobuf(3.0以上) (Protocol Buffers - Google’s data interchange format)
  • #安裝依賴工具
    sudo apt-get install autoconf automake libtool curl make g++ unzip

    #編譯安裝protobuf
    git clone https://github.com/protocolbuffers/protobuf.git
    cd protobuf
    git submodule update --init --recursive
    ./autogen.sh

    ./configure make make check sudo make install sudo ldconfig
  • 編譯 Linux 工具
    cd /path/to/MNN/
  • #編譯flatbuffer(pc平臺編譯器)等三方工具以及其他內容
    ./schema/genrate.sh
    ./tools/script/get_model.sh (可選, 模型僅demo工程需要)
    mkdir build && cd build

    #編譯 MNN 的各種benchmark, converter, quantools, demo, ealuation, test, demo等內容
    cmake … -DMNN_BUILD_CONVERTER=true -DMNN_BUILD_BENCHMARK=true -DMNN_BUILD_QUANTOOLS=true -DMNN_EVALUATION=true -DMNN_BUILD_TEST=true -DMNN_BUILD_TRAIN=true -DMNN_BUILD_TOOLS=true -DMNN_BUILD_DEMO=true
    make -j4

  • 編譯Android 庫
    #屬于交叉編譯, 原理是cmake 的 CMAKE_TOOLCHAIN_FILE指定交叉編譯文件 $ANDROID_NDK/build/cmake/android.toolchain.cmake (Android Studio 使用 cmake 也是這個原理)
    #所以事先需要在 ~/.bashrc 或者 ~/.bash_profile 中設置Android NDK 環境變量, 比如 export ANDROID_NDK=/opt/Android/Sdk/ndk/21.1.6352462
  • cd project/android

    #編譯armv7動態庫:
    mkdir build_32 && cd build_32 && …/build_32.sh

    #編譯armv8動態庫:
    mkdir build_64 && cd build_64 && …/build_64.sh

  • 編譯 iOS 庫
    在 macOS下, 用xcode打開 project/ios/MNN.xcodeproj, 點擊編譯即可

  • 查看內容

  • #查看 /MNN/build 目錄內容
    root@hemmingway-YangTianM4000e-06:/home/hemmingway/workspace_mnn/MNN/build# ls

    backendTest.out cmake_install.cmake MNNConvert pictureRotate.out testModel.out
    benchmarkExprModels.out dataTransformer.out MNNDump2Json quantized.out testModelWithDescrisbe.out
    benchmark.out express MNNV2Basic.out rawDataTransform.out timeProfile.out
    checkInvalidValue.out expressDemo.out mobilenetTest.out run_test.out tools
    classficationTopkEval.out getPerformance.out multiPose.out runTrainDemo.out train.out
    CMakeCache.txt libMNN.so OnnxClip segment.out transformer.out
    CMakeFiles Makefile pictureRecognition.out TestConvertResult

    #查看 MNN 的模型轉換工具 MNNConvert 的使用
    root@hemmingway-YangTianM4000e-06:/home/hemmingway/workspace_mnn/MNN/build# ./MNNConvert -h

    Usage:
    MNNConvert [OPTION…]

    -h, --help Convert Other Model Format To MNN Model

    -v, --version show current version
    -f, --framework arg model type, ex: [TF,CAFFE,ONNX,TFLITE,MNN]
    –modelFile arg tensorflow Pb or caffeModel, ex: *.pb,*caffemodel
    –prototxt arg only used for caffe, ex: *.prototxt
    –MNNModel arg MNN model, ex: *.mnn
    –fp16 save Conv’s weight/bias in half_float data type
    –benchmarkModel Do NOT save big size data, such as Conv’s weight,BN’s
    gamma,beta,mean and variance etc. Only used to test
    the cost of the model
    –bizCode arg MNN Model Flag, ex: MNN
    –debug Enable debugging mode.
    –forTraining whether or not to save training ops BN and Dropout,
    default: false

    root@hemmingway-YangTianM4000e-06:/home/hemmingway/workspace_mnn/MNN/build#

    #查看 /MNN/project/android 目錄內容
    root@hemmingway-YangTianM4000e-06:/home/hemmingway/workspace_mnn/MNN/project/android# ls
    build_32_ndk14.sh build_32_vulkan.sh build.gradle gradlew rTest.sh src
    build_32.sh build_64 build_vulkan.sh Hmacro.py run.sh testBasic.sh
    build_32_shared.sh build_64.sh CMakeExports.txt nativepub.gradle settings.gradle testCommon.sh
    build_32_stl_shared.sh build_gnu_32.sh gradle pullResult.sh speedTest.sh updateTest.sh

    總結

    以上是生活随笔為你收集整理的Ubuntu 18.04 LTS环境下 MNN 的编译与使用的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。