본문 바로가기

Programming/Mac

[Mac M1 Silicon(apple silicon)] MacOS Monterey tensorflow 2.6, numpy, pandas 설치

 

 

Apple M1 tensorflow 설정에서
tensorflow 2.x 버전은 Nvidia 뿐 아니라 다른 형상의 가속기들(ex. apple silicon)을 지원할 수 있는 device plug-in 을 지원합니다.

따라서 애플에서도 TF(tensorflow) 2.5 이상 버전을 설치하고 운용하는 방법에 대해 제시해주고 있습니다.
관련 내용은 아래 주소에서 확인 가능합니다.

https://developer.apple.com/metal/tensorflow-plugin/

 

Metal - Apple Developer

Find presentations, documentation, sample code, and resources for building macOS, iOS, and tvOS apps with the Metal framework.

developer.apple.com


오늘은 현재(2021-11-26)기준 mac os 최신 버전인 12.0.1 (Monterey)
에서 tensorflow 2.6 , numpy , pandas 를 설치하는 방법에 대해서 작성하겠습니다.

 


1. xcode-command-line-tool install

$ xcode-select --install

 


2. miniforge install

해당 링크에서 관련 shell 파일을 다운로드 받고 
그 아래의 명령어들을 수행해주시면 됩니다.

https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh

 

$ chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
$ sh ~/Downloads/Miniforge3-MacOSX-arm64.sh
$ source ~/miniforge3/bin/activate

 


3. conda 로 가상환경 만들기

 # 가상환경 생성
 $ conda create -n sample python=3.8
 # 가상환경 리스트
 $ conda env list
 # 가상환경 활성화
 $ conda activate sample

 


# 이 다음 스텝들은 모두 이전에 생성한 가상환경 활성화 시켜주시고 진행해주세요
$ conda activate sample

4. tensorflow 설치

$ conda install -c apple tensorflow-deps
$ python -m pip install tensorflow-macos
$ python -m pip install tensorflow-metal


tensrolfow 가 import 잘 되는지 확인

$ python
> import tensorflow as tf

 

만약에 import 하는데

 tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.

이러한 류의 에러가 나는 경우에는


자동으로 설치된 keras 버전이 2.7.0 인 경우 나는 오류임으로
keras 를 2.6.0 으로 downgrade 해줘야 합니다.
다음 명령으로 downgrade 할 수 있습니다.

 

$ python -m pip uninstall keras
$ python -m pip install keras==2.6.0

 


5. numpy & pandas 설치

$ python -m pip install numpy~=1.19.5
$ conda install pandas

 

 

 

반응형

'Programming > Mac' 카테고리의 다른 글

[Eclipse] Mac에서 Eclipse 여러 창 띄우기  (0) 2020.02.16