Run OpenVINO-2021.2, OpenCV-4.5.1-openvino on M1 MacBook Air with Intel Neural Compute Stick 2 (conda-forge/Miniforge)

Introduction



2020-12-19 시점 기록.

conda-forge/Miniforge에서는 Apple Silicon(M1) 대응(osx-arm64)이 앞서 있습니다.
numpy, scipy, matplotlib 등이 지원됩니다.

Work!! Intel Neural Compute Stick 2 (MYRIAD X) on Apple Silicon (M1) MacBook Air !!


환경


  • MacBook Air 2020 (M1, 2020)
  • Intel Compute Stick 2 (NCS2)
  • OpenVINO 2021.2 (No support CPU:arm)
  • OpenCV 4.5.1-openvino

  • Miniforge3 : cython
  • MacPorts: cmake automake autoconf wget libusb libtool

  • build OpenVINO 2021.2



    소스 트리



    NOTE: Don't work MacPorts's(Homebrew's) git-lfs yet. (2020-12-19)

    Download git-lfs from htps : // 기 tlfs. 기주 b. 코m/
    cp/usr/local/bin/git-lfs (x86_64)
    git clone -b 2021.2 https://github.com/openvinotoolkit/openvino.git openvino-2021.2
    cd openvino-2021.2
    git submodule update --init --recursive
    

    build



    Install dir/opt/arm64/openvino. Same as OpenVINO Distribution.
    (/usr/local로 여러가지 섞는 것이 싫고, Intel Ubuntu에서는 apt로 넣기 때문에 장소를 가지런히 하고 싶기 때문에)
    mkdir openvino-2021.2/build
    cd openvino-2021.2/build
    
    cmake \
        -DCMAKE_INSTALL_PREFIX=/opt/arm64/openvino_2021.2 \
        -DCMAKE_BUILD_TYPE=Release \
        -DENABLE_PYTHON=ON \
        -DPYTHON_EXECUTABLE=$HOME/miniforge3/bin/python3.9 \
        -DPYTHON_LIBRARY=$HOME/miniforge3/lib/libpython3.9.dylib \
        -DPYTHON_INCLUDE_DIR=$HOME/miniforge3/include/python3.9 \
        ..
    
    make -j 8
    sudo make install
    sudo ln -s /opt/arm64/openvino_2021.2 /opt/arm64/openvino
    

    if use zsh, patch it.
    *** setupvars.sh.orig   2020-12-17 12:28:59.000000000 +0900
    --- setupvars.sh    2020-12-17 12:29:34.000000000 +0900
    ***************
    *** 18,23 ****
    --- 18,24 ----
      BASE_DIR="$( dirname "$SCRIPT_DIR" )"
    
      INSTALLDIR="${BASE_DIR}"
    + INSTALLDIR=/usr/local
    

    environment valiable
    source /opt/arm64/openvino/bin/setupvars.sh
    export ngraph_DIR=/opt/arm64/openvino/cmake
    export OpenCV_DIR=/opt/arm64/openvino/opencv
    export PYTHONPATH=/opt/arm64/openvino/opencv/lib/python3.9/site-packages:$PYTHONPATH
    export LD_LIBRARY_PATH=/opt/arm64/openvino/lib:$LD_LIBRARY_PATH
    

    build OpenCV



    소스 트리


    git clone --depth 1 -b 4.5.1-openvino https://github.com/opencv/opencv.git opencv-4.5.1-openvino
    

    build



    Install dir/opt/arm64/openvino/opencv. Same as OpenVINO Distribution.
    mkdir opencv-4.5.1-openvino/build
    cd opencv-4.5.1-openvino/build
    
    cmake \
        -DCMAKE_INSTALL_PREFIX=/opt/arm64/openvino_2021.2/opencv \
        -DCMAKE_BUILD_TYPE=Release \
        -DWITH_INF_ENGINE=ON \
        -DENABLE_CXX11=ON \
        -DWITH_TBB=ON \
        -DENABLE_PYTHON=ON \
        -DPYTHON3_EXECUTABLE=$HOME/miniforge3/bin/python3.9 \
        -DPYTHON3_LIBRARY=$HOME/miniforge3/lib/libpython3.9.dylib \
        -DPYTHON3_INCLUDE_DIR=$HOME/miniforge3/include/python3.9 \
        ..
    
    make -j 8
    sudo make install
    

    Run with Intel Neural Compurte Stick 2


    python opencv-4.5.1-openvino/samples/python/video_threaded.py
    
    python /opt/arm64/openvino/deployment_tools/inference_engine/samples/python/classification_sample_async/classification_sample_async.py -m alexnet.xml -d MYRIAD -i image.jpg
    

    Run Success!! 파이썬에서도 작동합니다.

    Reference


  • OpenVINO wiki: BuildingForMacOS

  • Note



    pytorch 가 빨리 Apple Silicon(M1) 대응되도록!

    좋은 웹페이지 즐겨찾기