오늘 새벽 m1 macbook pro 개발환경 셋팅하면서 빠르고 깔끔하게 설치되는 것만 정리했습니다 :)
상세한 설명보다는 빠른 작동 가능한 것 위주로 정리할게요
Homebrew
oh-my-zsh
python
conda
tensorflow
관련 패키지들
순서로 설치했습니다.
M1 Mac에서 HomeBrew를 설치하는 방법
# We'll be installing Homebrew in the /opt directory.
cd /opt
# Create a directory for Homebrew. This requires root permissions.
sudo mkdir homebrew
# Make us the owner of the directory so that we no longer require root permissions.
sudo chown -R $(whoami) /opt/homebrew
# Download and unzip Homebrew. This command can be found at https://docs.brew.sh/Installation.
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
# Add the Homebrew bin directory to the PATH. If you don't use zsh, you'll need to do this yourself.
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc
oh-my-zsh 설치방법
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
테마 바꾸실 분은 이글 참조 https://velog.io/@saemsol/Oh-My-Zsh
python
맥북의 경우 파이썬 2.xx대 버전이 설치되어 있습니다.
brew를 통해 설치해줍니다.
brew install python
conda
anaconda는 m1을 공식 호환하고있는 Miniforge3으로 설치합니다.
아래 링크 클릭하셔서 Miniforge3 설치파일 다운받은 후
https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
cd ~/Downloads/
bash Miniforge3-MacOSX-arm64.sh
위와 같이 설치하신 후 터미널 껐다켠 후
conda -V
python3 -V
anaconda 설치 관련 다양한 에러 관련 확인이 필요한 분은 이글 참조 https://cpuu.postype.com/post/9077219
conda 가상환경 구축
m1 맥에서 tensorflow는 버전 3.8 기준으로 배포되어 있습니다. 버전 3.8로 지정해서 설치합니다.
conda install python=3.8
conda create --name tf python=3.8
conda activate tf
conda info --envs
conda install -y pandas matplotlib scikit-learn jupyterlab
(추후 가상환경 사용 종료시 아래 명령어)
conda deactivate
m1에 tensorflow 설치하기
오랜만에 처음부터 다시 셋팅하던 중 최신 버전의 글이 있어 참고했다.
명령어만 요약하면 아래와 같다 (상세 설명은 아래 링크 참조)
# M1용 Miniforge Shell Script 다운로드
https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
# 다운받은 Miniforge 실행
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
source ~/miniforge3/bin/activate
# Conda 환경 생성 및 실행
conda create --name tfenv python=3.8
conda activate tfenv
# M1 실리콘용 Tensorflow 설치
conda install -c apple tensorflow-deps==2.5.0
tensorflow-macos==2.5.0
tensorflow-metal==0.1.2
https://velog.io/@psjlmk/M1-%EB%A7%A5%EB%B6%81-tensorflow-%EC%84%A4%EC%B9%98
https://hardenkim.github.io/etc/etc-7/
conda 를 이용해 tensorflow 설치하기
conda install -c conda-forge tensorflow
conda 가상환경에 Apple Tensorflow 직접 설치하기 (직접 설치가 필요할 경우)
텐서플로우는 아직 m1 맥 설치는 좀 제한적인데요. (2021 7월 기준)
관련 패키지들을 애플 깃허브에서 제공하는 파일을 받아서 설치해야 합니다.
아래 링크에서 현재 release된 버전 중 원하는 버전을 선택해서 .tar.gz 압축파일 다운로드 하면되고
https://github.com/apple/tensorflow_macos/releases
저는 최신버전인 v0.1alpha3 선택했습니다. (아래 코드는 이 버전 기준으로 작성됨)
압축파일을 열어보면 m1용 arm64관련 설치 파일들을 확인할 수 있어요
github에서 Script를 제공하지만, Conda 환경에 설치할거라 위 Script 이용은 패스하고 아래와 같이 설치
cd Downloads/tensorflow_macos/arm64
pip3 install --force pip==20.2.4 wheel setuptools cached-property six packaging
pip3 install --upgrade --no-dependencies --force grpcio-1.33.2-cp38-cp38-macosx_11_0_arm64.whl h5py-2.10.0-cp38-cp38-macosx_11_0_arm64.whl numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl tensorflow_addons_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl
pip3 install --upgrade --force --no-dependencies tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl
pip3 install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard --use-feature=2020-resolver
tensorflow 버전 관련 삽질은 이분이 다 해주셨습니다 (감사합니다!)
버전 관련 에러를 겪고있을 경우 이글 참조
https://shanepark.tistory.com/68
설치 끝!