01-ubuntu编译ncnn

本文介绍了如何在Ubuntu18.04上从源码编译安装轻量级高性能的神经网络推理框架NCNN。文章详细记录了所需的依赖包安装步骤,包括cmake、protobuf及opencv等,并提供了编译验证的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

服务器操作系统

Ubuntu 18.04


   
  1. ~ # cat /proc/version
  2. Linux version 4.15 .0 -72- generic (buildd@lcy01-amd64 -026) (gcc version 7.4 .0 (Ubuntu 7.4 .0 -1ubuntu1~ 18.04 .1)) # 81-Ubuntu SMP Tue Nov 26 12: 20: 02 UTC 2019

编译过程

更新系统

sudo apt-get update
   

安装 NCNN 需要的包

NCNN 需要使用包包括:g++、cmake、protobuf、opencv。其中 protobuf 和 opencv 在 Ubuntu18.04 已经有库文件了,直接安装库就可以。

安装 cmake

sudo apt install cmake
   

安装 protobuf 库

sudo apt install protobuf-compiler libprotobuf-dev
   

安装 opencv 库

sudo apt install libopencv-dev
   

下载 NCNN 包

下载ncnn源码(https://github.com/Tencent/ncnn/releases)。下载后是一个 zip 文件,解压之。

unzip ncnn-master.zip
   

编译 NCNN


   
  1. cd ncnn-master
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make
  6. make install

然后就耐心的等着吧。

验证

编译成功后,在 build 目录下将多出编译结果。将编译出来的 benchmark 可执行文件拷贝到 ncnn/benchmark 目录下。


   
  1. /ncnn-master/build # cd ../benchmark
  2. /ncnn-master/benchmark # cp ../build/benchmark/benchncnn .
  3. /ncnn-master/benchmark # ./benchncnn

这样我们可以得到如下的允许测试结果。

常见问题

1、有些人的机器上有多个版本的 protoc,可以通过 which protoc,查看当前使用的版本,在通过配置路径来解决。

2、没有指定安装路径。make install 后是安装在当前路径下 install 目录下。如下图。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值