如何在M1 Macbook上配置OpenCV等機器學習環(huán)境?
設置Xcode
打開終端并執(zhí)行
sudo xcode-select --install
安裝HomeBrew(原生Apple Silicon M1)
打開終端,逐個寫入
這將為M1芯片安裝最新的Brew/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo “export PATH=/opt/homebrew/bin:$PATH” >> ~/.zshrc
//Restart The Terminal
brew install gcc
brew install cmake
brew install wget
安裝Miniforge,設置Conda環(huán)境點擊下面的鏈接下載(Apple Silicon)版本https://github.com/conda-forge/miniforge
打開終端并執(zhí)行以下操作// If the Downloaded File Stored in Download
cd Downloads
bash Miniforge3-MacOSX-arm64.sh
//After Installation Completes Restart Terminal
//Creating Conda Environment named ml You can use any name in place of "ml"
conda create --name ml
conda install -y python==3.8.6
conda install -y pandas matplotlib scikit-learn jupyterlab
安裝Tensorflow單擊下面的鏈接并下載文件https://github.com/apple/tensorflow_macos/releasesAm在2021年3月3日為M1使用最新的TF alpha 2版本。
//if Download Directory is Downloads
cd Downloads
tar xvf tensorflow_macos-0.1alpha2.tar.gz
cd tensorflow_macos/arm64
//Dont Forget To Activate Conda Environment
conda activate ml
// Install specific pip version and some other base packages
pip install --force pip==20.2.4 wheel setuptools cached-property six
// Install all the packages provided by Apple but TensorFlow
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.1a2-cp38-cp38-macosx_11_0_arm64.whl
// Install additional packages
pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
// Install TensorFlow
pip install --upgrade --force --no-dependencies tensorflow_macos-0.1a2-cp38-cp38-macosx_11_0_arm64.whl
安裝額外的包pip install matplotlib
conda install -c conda-forge scikit-learn
pip install keras
pip install notebook
編譯和安裝OpenCV//I Suggest To Do all this Inside miniforge3 dir for that
// cd miniforge3
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.5.0.zip
unzip opencv.zip
unzip opencv_contrib.zip
cd opencv-4.5.0
mkdir build && cd build
//Here Take Care Of Paths of OPENCV_EXTRA_MODULES_PATH and
// PYTHON3_EXECUTABLE If you're Beginner watch the YouTube video
//And If Inside miniforge3 just place your <username>.
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/<username>/miniforge3/opencv_contrib-4.5.0/modules
-D PYTHON3_EXECUTABLE=/Users/<username>/miniforge3/envs/ml/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
//"8" is the number of cores To be used(This Step Takes Time)
sudo make install
//Linking OpenCV To Conda Environment
mdfind cv2.cpython
//From the output Copy the Path similar to the below one
"/usr/local/lib/python3.8/site-packages/cv2/python-3.8/cv2.cpython-38-darwin.so cv2.so"
cd
cd miniforge3/envs/dev/lib/python3.8/site-packages
ln -s PasteYourCopiedPathHere
請輸入評論內(nèi)容...
請輸入評論/評論長度6~500個字
最新活動更多
-
即日-10.29立即報名>> 2024德州儀器嵌入式技術(shù)創(chuàng)新發(fā)展研討會
-
10月31日立即下載>> 【限時免費下載】TE暖通空調(diào)系統(tǒng)高效可靠的組件解決方案
-
即日-11.13立即報名>>> 【在線會議】多物理場仿真助跑新能源汽車
-
11月14日立即報名>> 2024工程師系列—工業(yè)電子技術(shù)在線會議
-
12月19日立即報名>> 【線下會議】OFweek 2024(第九屆)物聯(lián)網(wǎng)產(chǎn)業(yè)大會
-
即日-12.26火熱報名中>> OFweek2024中國智造CIO在線峰會
推薦專題
- 1 Intel宣布40年來最重大轉(zhuǎn)型:年底前裁員15000人、拋掉2/3房產(chǎn)
- 2 因美封殺TikTok,字節(jié)股價骨折!估值僅Meta1/5
- 3 宏山激光重磅發(fā)布行業(yè)解決方案,助力智能制造產(chǎn)業(yè)新飛躍
- 4 國產(chǎn)AI芯片公司破產(chǎn)!白菜價拍賣
- 5 具身智能火了,但規(guī)模落地還需時間
- 6 國產(chǎn)英偉達們,抓緊沖刺A股
- 7 三次錯失風口!OpenAI前員工殺回AI編程賽道,老東家捧金相助
- 8 英特爾賦能智慧醫(yī)療,共創(chuàng)數(shù)字化未來
- 9 英偉達的麻煩在后頭?
- 10 將“網(wǎng)紅”變成“商品”,AI“爆改”實力拉滿
- 高級軟件工程師 廣東省/深圳市
- 自動化高級工程師 廣東省/深圳市
- 光器件研發(fā)工程師 福建省/福州市
- 銷售總監(jiān)(光器件) 北京市/海淀區(qū)
- 激光器高級銷售經(jīng)理 上海市/虹口區(qū)
- 光器件物理工程師 北京市/海淀區(qū)
- 激光研發(fā)工程師 北京市/昌平區(qū)
- 技術(shù)專家 廣東省/江門市
- 封裝工程師 北京市/海淀區(qū)
- 結(jié)構(gòu)工程師 廣東省/深圳市