Apple Silicon M1: OpenVINO-2021.3, OpenCV-4.5.2-openvino
Introduction
2021-03-26 시점의 내용.
Apple Silicon M1로 빌드하자. OpenVINO도 Neural Compute Stick 2라면 움직입니다.
환경
MacPorts
Miniforge3
build OpenCV 4.5.2-openvino
소스 트리
git clone --depth 1 -b 4.5.2-openvino https://github.com/opencv/opencv.git opencv-4.5.2-openvino
build
Install dir/opt/intel/openvino/opencv. Same as OpenVINO Distribution.
mkdir opencv-4.5.2-openvino/build
cd opencv-4.5.2-openvino/build
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/intel/openvino/opencv \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_INF_ENGINE=ON \
-DENABLE_CXX11=ON \
-DWITH_TBB=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 4
sudo make install
build OpenVINO 2021.3
소스 트리
git clone -b 2021.2 https://github.com/openvinotoolkit/openvino.git openvino-2021.3
cd openvino-2021.3
git submodule update --init --recursive
build
Install dir/opt/intel/openvino. Same as OpenVINO Distribution.
mkdir openvino-2021.3/build
cd openvino-2021.3/build
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/intel/openvino \
-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 4
sudo make install
patch this.
*** 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=/opt/intel/openvino
environment valiable
source /opt/intel/openvino/bin/setupvars.sh
export ngraph_DIR=/opt/intel/openvino/deployment_tools/ngraph/cmake
export OpenCV_DIR=/opt/intel/openvino/opencv
export PYTHONPATH=$OpenCV_DIR/lib/python3.9/site-packages:$PYTHONPATH
※ 서로 의존하고 있으므로 OpenCV → OpenVINO → OpenCV에서 빌드&설치하는 것.
Run with Intel Neural Compurte Stick 2
python opencv-4.5.2-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
git clone --depth 1 -b 4.5.2-openvino https://github.com/opencv/opencv.git opencv-4.5.2-openvino
mkdir opencv-4.5.2-openvino/build
cd opencv-4.5.2-openvino/build
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/intel/openvino/opencv \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_INF_ENGINE=ON \
-DENABLE_CXX11=ON \
-DWITH_TBB=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 4
sudo make install
git clone -b 2021.2 https://github.com/openvinotoolkit/openvino.git openvino-2021.3
cd openvino-2021.3
git submodule update --init --recursive
mkdir openvino-2021.3/build
cd openvino-2021.3/build
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/intel/openvino \
-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 4
sudo make install
*** 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=/opt/intel/openvino
source /opt/intel/openvino/bin/setupvars.sh
export ngraph_DIR=/opt/intel/openvino/deployment_tools/ngraph/cmake
export OpenCV_DIR=/opt/intel/openvino/opencv
export PYTHONPATH=$OpenCV_DIR/lib/python3.9/site-packages:$PYTHONPATH
python opencv-4.5.2-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
(최소 스텝 밖에 쓰고 있지 않기 때문에) 여기에 써 있는 채로 잘 가지 않거나, 환경을 다소 변경하고 싶은 경우는 이하에 눈을 통하면 할 수 있지 않을까.
TODO
Reference
이 문제에 관하여(Apple Silicon M1: OpenVINO-2021.3, OpenCV-4.5.2-openvino), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/kose3/items/2863791559cad7a3932f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)