맥북 M1 pro에 Tensorflow, Keras 개발 환경 세팅하기
본문 바로가기
AI 구현/환경 세팅

맥북 M1 pro에 Tensorflow, Keras 개발 환경 세팅하기

by NEWSUN* 2023. 10. 30.

 

Visual Studio Code에서 구동하였습니다.

 

1. Motivation

딥러닝 공부를 위해서 Tensorflow 환경을 세팅해야 했습니다. M1의 경우 anaconda에서 tensorflow, keras 지원을 안한다고 들어서 miniforge를 이용해 tensorflow, keras를 설치하였습니다. miniforge는 anaconda의 축소 버전입니다.

 

 

2. miniforge 다운로드

https://github.com/conda-forge/miniforge

 

GitHub - conda-forge/miniforge: A conda-forge distribution.

A conda-forge distribution. Contribute to conda-forge/miniforge development by creating an account on GitHub.

github.com

M1칩을 쓰고 있다면 Miniforge3-MacOSX-arm64 를 선택하세요.

 

파일을 다운로드 받았다면 아래 코드를 순서대로 실행해주세요. 

 

# Miniforge 다운로드
chmod +x ~/Downloads/Miniforge3-MacOSX-arm64.sh
sh ~/Downloads/Miniforge3-MacOSX-arm64.sh

# Miniforge 가상환경 실행
source ~/miniforge3/bin/activate

 

Thank you for installing Miniforge3! 라는 문장이 떴다면 축하드립니다. 제대로 다운로드 받으신 거예요.

 

 

3. miniforge 가상환경 생성 및 tensorflow, keras 모듈 설치

conda create --name vven python=3.9 
conda activate vven

# Install the Tensorflow dependencies 
conda install -c apple tensorflow-deps 

# Install base tensorflow 
python -m pip install tensorflow-macos 

# Install metal plugin 
python -m pip install tensorflow-metal

 

 

https://jongsky.tistory.com/34

 

M1 Mac에서 tensorflow, keras 설치하기

1. 글을 쓰게 된 계기 프로젝트에서 데이터 전처리를 하며 자연어처리를 하는 과정 중 m1 anaconda 환경에서는 tensorflow와 keras를 지원하지 않는 것을 확인했다.... (얼른 anaconda 환경에서도 tensorflow와

jongsky.tistory.com

https://developer.apple.com/forums/thread/721619

 

Tensorflow on M1 Macbook Pro, erro… | Apple Developer Forums

It doesn't matter if I install miniforge or mamba, directly or through brew, when I try to fit the sample model from https://developer.apple.com/metal/tensorflow-plugin/, even with a simple sequential model, I always get this error. Is there any workaround

developer.apple.com