注意:如果尚未安装 OpenCV,请先安装它。
# check for updates (64-bit OS is still under development!)
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install cmake wget
$ sudo apt-get install libprotobuf-dev protobuf-compiler
# download ncnn
$ git clone --depth=1 https://github.com/Tencent/ncnn.git
# install ncnn
$ cd ncnn
$ mkdir build
$ cd build
# build 64-bit ncnn
$ cmake -D NCNN_DISABLE_RTTI=OFF \
-D CMAKE_TOOLCHAIN_FILE=../toolchains/aarch64-linux-gnu.toolchain.cmake ..
$ make -j4
$ make install
# copy output to dirs
$ sudo mkdir /usr/local/lib/ncnn
$ sudo cp -r install/include/ncnn /usr/local/include/ncnn
$ sudo cp -r install/lib/libncnn.a /usr/local/lib/ncnn/libncnn.a
# once you've placed the output in your /usr/local directory,
# you may delete the ncnn directory if you have no tools or examples compiled
$ cd ~
$ sudo rm -rf ncnn
sudo /sbin/ldconfig
# check for updates
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install cmake wget
$ sudo apt-get install libprotobuf-dev protobuf-compiler
# download ncnn
$ git clone --depth=1 https://github.com/Tencent/ncnn.git
# install ncnn
$ cd ncnn
$ mkdir build
$ cd build
# build 32-bit ncnn
$ cmake -D PI3=ON \
-D NCNN_DISABLE_RTTI=OFF \
-D CMAKE_EXE_LINKER_FLAGS=-ldl \
-D CMAKE_TOOLCHAIN_FILE=../toolchains/pi3.toolchain.cmake ..
$ make -j4
$ make install
# copy output to dirs
$ sudo mkdir /usr/local/lib/ncnn
$ sudo cp -r install/include/ncnn /usr/local/include/ncnn
$ sudo cp -r install/lib/libncnn.a /usr/local/lib/ncnn/libncnn.a
# once you've placed the output in your /usr/local directory,
# you may delete the ncnn directory if you have no tools or examples compiled
$ cd ~
$ sudo rm -rf ncnn
sudo /sbin/ldconfig
如果一切顺利,您将获得两个文件夹。一个包含所有头文件,另一个包含库,如屏幕转储中所示。
另请注意包含示例的文件夹。这里涵盖了许多不同类型的深度学习。由于 ncnn 库中的版本更改,对实际深度学习模型的引用有时会导致错误。
默认cmake、Protobuf、opencv都已安装。
如果尝试最新版本报错,则装这个版本:
原地址:https://github.com/alibaba/MNN/tree/6b0c16f24f222239ecce8fb61c51b7f267502670
快速下载地址:https://hub.fastgit.org/alibaba/MNN.git
编辑CMakeLists
,打开OpenCL
选项。
option(MNN_OPENCL "Enable OpenCL" ON)
sudo apt-get install ocl-icd-opencl-dev -y
./schema/generate.sh
mkdir build
cd build
cmake .. -DMNN_BUILD_CONVERTER=true -DMNN_SEP_BUILD=false
make -j4
sudo make install
sudo /sbin/ldconfig