본문 바로가기

머신러닝

맥(Mac)에 텐서플로(Tensorflow) 사용환경 갖추기

설치과정은 https://www.youtube.com/watch?v=MpUvdLD932c 를 참고하였고, 동영상은 2020년 1월에 업로드 되었으며, 아래는 동영상 내용을 요약한 것이다.

 

 

1. Miniconda3 다운로드

구글에서 검색 (https://docs.conda.io/en/latest/miniconda.html)

 

 

Miniconda — Conda documentation

Miniconda Miniconda is a free minimal installer for conda. It is a small, bootstrap version of Anaconda that includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others. Use th

docs.conda.io

 

2. Miniconda3 설치

설치 후 터미널을 실행시키면 (base)라는 가상환경이 동작하는 것을 확인할 수 있다.

 

3. Jupyter 설치

터미널에서 다음과 같이 입력하면 (base) 환경에 jupyter가 설치된다.

 

conda install jupyter

 

4. Environment Setup Script 파일 다운로드

https://github.com/jeffheaton/t81_558_deep_learning에서 아래로 스크롤하면, tensorflow.yml이라는 파일이 보이며, 이 파일을 다운로드하여 홈디렉토리에 tensorflow.yml로 저장한다. 파일의 내용은 아래와 같다.

 

jeffheaton/t81_558_deep_learning

Washington University (in St. Louis) Course T81-558: Applications of Deep Neural Networks - jeffheaton/t81_558_deep_learning

github.com

 

name: tensorflow

dependencies:
      - python=3.7
      - pip>=19.0
      - jupyter
      - tensorflow=2.0
      - scikit-learn
      - scipy
      - pandas
      - pandas-datareader
      - matplotlib
      - pillow
      - tqdm
      - requests
      - h5py
      - pyyaml
      - flask
      - boto3
      - pip:
            - bayesian-optimization
            - gym
            - kaggle

 

5. Environment Setup Script 파일 실행

터미널에서 다음과 같이 실행하면 (tensorflow) 가상환경이 설치되고, 그 환경에 위 파일 내용이 설치된다. 시간이 조금 걸린다.

 

conda env create -v -f tensorflow.yml

 

6. 가상환경

다음의 명령으로 (tensorflow) 가상환경을 활성화시킨다.

 

conda activate tensorflow


다음의 명령으로 (tensorflow) 가상환경을 비활성화 시킬 수 있다.

 

conda deactivate

 

7. (tensorflow) 가상환경에 jupyter 커널 설치

(tensorflow) 가상환경 상태에서 다음의 명령을 입력한다.

 

python -m ipykernel install --user --name tensorflow --display-name "Python3.7 (tensorflow)"

 

jupyter notebook을 실행하고, 커널에서 Python3.7 (tensorflow)를 선택하면 tensorflow를 사용할 수 있다.