0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CoreMP135でncnnをクロスコンパイルしてbenckmarkを実行する手順

Last updated at Posted at 2024-07-03

目的

PC(Ubuntu)にクロスコンパイル環境を構築して、ディープラーニングフレームワークのncnnとベンチマークソフトウェアのbenchmarkビルドし、CoreMP135でncnn benchmarkを実行します。

また、こちらのリポジトリで、これまでにCoreMP135、Raspberry Pi Zero 2 W、M5Stack_UnitV2、LicheeNano RV、Luckfox Pico Maxでのncnn benchmarkを比較した結果を公開しています。

PC環境

まず以下のバージョンのUbuntuをインストールしたPC環境で、クロスコンパイル環境を構築します。

Ubuntu 22.04.3 LTS(x64)

コンパイルにツールチェインのインストール

コンパイルに必要なツールチェインを含むパッケージをaptからインストールします

$ sudo apt install crossbuild-essential-armhf crossbuild-essential-arm64

以下のコマンドを実行して、コンパイラのバージョン情報が出てれくれば、ツールチェインのインストールが完了です。

$ arm-linux-gnueabihf-g++ -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/11/lto-wrapper
Target: arm-linux-gnueabihf
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

ncnnのインストール

ncnnは、Tencentが開発しているモバイルプラットフォーム向けに最適化された高性能なニューラルネットワーク推論コンピューティングフレームワークです。

このシェルスクリプトで、ARMプロセッサ向けにncnnライブラリをgitからクローン、ビルド、そしてインストールします。

$ git clone https://github.com/Tencent/ncnn.git -b 20240410 --depth 1 
$ cd ncnn/
$ cmake -B build/arm_coremp135 -DCMAKE_TOOLCHAIN_FILE=./toolchains/arm-linux-gnueabihf.toolchain.cmake -DNCNN_SIMPLEOCV=ON -DCMAKE_BUILD_TYPE=Release -DNCNN_VULKAN=OFF -DNCNN_BUILD_EXAMPLES=OFF .
$ cmake --build build/arm_coremp135 &&  cmake --install build/arm_coremp135 --prefix install/arm_coremp135

ncnn benckmarkのインストール

ncnnディレクトリ内でbenckmarkのファイルを整理し、それをzip圧縮します。

$ cd ncnn
$ mkdir install/arm_coremp135/benchmark
$ cp ./build/arm_coremp135/benchmark/benchncnn ./install/arm_coremp135/benchmark
$ cp ./benchmark/*.param ./install/arm_coremp135/benchmark
$ zip -r ./install/arm_coremp135/arm_coremp135_ncnn_benchmark.zip ./install/arm_coremp135/benchmark

CoreMP135でのベンチマークの実行

zipファイルをCoreMP135にscpでコピー、CoreMP135でncnn benchmarkを実行します。

# unzip arm_coremp135_ncnn_benchmark.zip 
# cd benchmark
#  ./benchncnn 4 1 0 -1 1
loop_count = 4
num_threads = 1
powersave = 0
gpu_device = -1
cooling_down = 1
          squeezenet  min =  531.80  max =  532.63  avg =  532.20
     squeezenet_int8  min =  361.08  max =  361.75  avg =  361.39
           mobilenet  min =  932.67  max =  934.00  avg =  933.25
      mobilenet_int8  min =  497.71  max =  498.07  avg =  497.87
        mobilenet_v2  min =  614.77  max =  616.07  avg =  615.46
        mobilenet_v3  min =  492.15  max =  493.12  avg =  492.77
          shufflenet  min =  307.61  max =  308.09  avg =  307.83
       shufflenet_v2  min =  289.53  max =  290.40  avg =  289.82
             mnasnet  min =  603.62  max =  604.35  avg =  603.87
     proxylessnasnet  min =  685.61  max =  686.89  avg =  686.26
     efficientnet_b0  min = 1001.24  max = 1001.77  avg = 1001.49
   efficientnetv2_b0  min = 1177.08  max = 1179.96  avg = 1178.58
        regnety_400m  min =  721.99  max =  722.87  avg =  722.29
           blazeface  min =   84.75  max =   85.43  avg =   85.08
           googlenet  min = 1741.78  max = 1744.97  avg = 1742.84
      googlenet_int8  min = 1090.19  max = 1091.28  avg = 1090.78
            resnet18  min = 1568.05  max = 1569.53  avg = 1568.86
       resnet18_int8  min =  810.82  max =  811.99  avg =  811.28
             alexnet  min = 1006.04  max = 1007.20  avg = 1006.40

CoreMP135でncnnをクロスコンパイルしてbenckmarkを実行することができました。

参考資料

参考資料

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?