最近被安排研究ncnn的效果,ncnn不能支持gpu加速。
先说一下具体环境,使用的是Ubuntu16.04
-
首先安装git
sudo apt-get install git -
然后下载源码
git clone https://github.com/Tencent/ncnn.git -
安装opencv2.4.13.6 (源码包)
按官方文档走https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html -
安装protobuf3.6.1 (源码包)
按官方文档走https://github.com/protocolbuffers/protobuf/blob/master/src/README.md -
看看官方文档,Build for Linux x86一节
https://github.com/Tencent/ncnn/wiki/how-to-build
Build for Linux x86
$ cd <ncnn-root-dir>
$ mkdir -p build
$ cd build
$ cmake ..
$ make -j4
uncomment add_subdirectory(examples)
in CMakeLists.txt with your favourite editor
$ mkdir -p build
$ cd build
$ cmake ..
$ make -j4
copy examples/squeezenet_v1.1.param to build/examples
copy examples/squeezenet_v1.1.bin to build/examples
./squeezenet yourimage.jpg
output top-3 class-id and score
you may refer examples/synset_words.txt to find the class name
404 = 0.990290
908 = 0.004464
405 = 0.003941
PS:
我开始编译ncnn失败,发现需要加C++11,
在CMakeLists.txt里,加入了这句
set(CMAKE_CXX_FLAGS "-std=c++11")
网友评论