Ubuntu下编译ncnn

服务器操作系统

Ubuntu 18.04

~# cat /proc/version
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

cd ncnn-master
mkdir build
cd build
cmake ..
make
make install

然后就耐心的等着吧。

验证

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

/ncnn-master/build# cd ../benchmark
/ncnn-master/benchmark# cp ../build/benchmark/benchncnn .
/ncnn-master/benchmark# ./benchncnn

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

常见问题

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

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

发布了268 篇原创文章 · 获赞 309 · 访问量 108万+

猜你喜欢

转载自blog.csdn.net/justidle/article/details/104948080