MMDeploy sdk installation (ncnn)

Home: mmpose/projects/rtmpose at main · open-mmlab/mmpose · GitHub

1. Install the build and compile toolchain

  • cmake

        Make sure the version of cmake >= 3.14.0 . If not, you can refer to the following command to install version 3.20.0.

wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-x86_64.tar.gz
tar -xzvf cmake-3.20.0-linux-x86_64.tar.gz
sudo ln -sf $(pwd)/cmake-3.20.0-linux-x86_64/bin/* /usr/bin/
  • GCC 7+

         MMDeploy SDK uses C++17 features, so gcc version 7+ or above needs to be installed.

# 如果 Ubuntu 版本 < 18.04,需要加入仓库
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-7
sudo apt-get install g++-7

2. Install MMDeploy SDK dependencies

  • opencv

        On Ubuntu 18.04 and above. OpenCV (>=3.0).


sudo apt-get install libopencv-dev

        In Ubuntu 16.04, OpenCV needs to be installed from source. You can refer to my previous blog. Installed ncnn by the way.

Install NCNN and Opencv on Ubuntu 16.04

3. Install the inference engine (ncnn)

        MMDeploy's Model Converter and SDK share the inference engine. You can choose the inference engine installation you are interested in. I choose ncnn platform. Pwd is /home/hhzdh-linux/ncnn as mine. How to install ncnn can also refer to my previous blog.

cd ncnn
export NCNN_DIR=$(pwd)

Install NCNN and Opencv on Ubuntu 16.04

4. Compile MMDeploy

        It is necessary to surf the Internet scientifically, otherwise it will be very slow.

git clone https://github.com/open-mmlab/mmdeploy.git
cd mmdeploy
git submodule update --init --recursive

        Compile the Model Converter. If I choose the ncnn inference backend, I need to compile the corresponding custom operator library. You may encounter errors when compiling  undefined reference to __atomic_fetch_add_8, and you need to add cmake options 

# 记得sudo
cd ${MMDEPLOY_DIR}
mkdir -p build && cd build
cmake -DCMAKE_CXX_COMPILER=g++-7 -DMMDEPLOY_TARGET_BACKENDS=ncnn -Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn 
make -j$(nproc) && make install
cmake -DCMAKE_CXX_COMPILER=g++-7 -DMMDEPLOY_TARGET_BACKENDS=ncnn -Dncnn_DIR=${NCNN_DIR}/build/install/lib/cmake/ncnn -DCMAKE_CXX_FLAGS=-latomic

        So far the installation of mmdeploy sdk (ncnn) is complete.

Five, sdk use

        In cmakelist need to add the following:

set(CMAKE_PREFIX_PATH ../Downloads/ncnn/build/install ../Downloads/mmdeploy/build/install)
find_package(MMDeploy REQUIRED)

target_link_libraries(${name} PRIVATE mmdeploy ${OpenCV_LIBS})

        For specific usage, please refer to: MMDeploy SDK Usage Record (ncnn)_HHzdh's Blog-CSDN Blog

Guess you like

Origin blog.csdn.net/weixin_44855366/article/details/131301945