내용 |
맥북 M1칩에 텐서플로우와 OpenCV 설치하기
Install Tensorflow 2.4 and OpenCV4 on Macbook pro M1
주의 : 응용프로그램 -> 유틸리티 -> 터미널에서 오른쪽 버튼 -> 정보 가져오기 -> Rosetta를 사용하여 열기에 체크되어 있음 안됨
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install wget
brew install cmake
curl -fLO https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha3/tensorflow_macos-0.1alpha3.tar.gz
tar xvf tensorflow_macos-0.1alpha0.tar.gz
cd tensorflow_macos
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh
conda create -n tf python=3.8
conda activate tf
pip install jupyterlab
jupyter notebook
pip install --upgrade pip
pip install --force wheel setuptools cached-property six packaging
cd ~/tensorflow_macos/arm64/
pip install --upgrade --no-dependencies --force numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl tensorflow_addons_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl
pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
pip install --upgrade --force --no-dependencies tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl
wget -O opencv-4.5.1.zip https://github.com/opencv/opencv/archive/4.5.1.zip
wget -O opencv_contrib-4.5.1.zip https://github.com/opencv/opencv_contrib/archive/4.5.1.zip
unzip opencv.zip
unzip opencv_contrib.zip
cd opencv-4.5.0
mkdir build && cd build
cmake \
-DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DWITH_OPENJPEG=OFF \
-DWITH_IPP=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=/Users/jk/opencv_contrib-4.5.1/modules \
-D PYTHON3_EXECUTABLE=/Users/jk/miniforge3/envs/tf/bin/python3 \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D BUILD_EXAMPLES=ON ..
make -j8
sudo make install
mdfind cv2.cpython
cd ~/miniforge3/envs/tf/lib/python3.8/site-packages
ln -s /usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.cpython-38-darwin.so cv2.so |