jupyter notebook을 설치하여 Apple M2 GPU를 사용하는 환경을 마련해 보자
brew install --cask anaconda
export PATH="/opt/homebrew/anaconda3/bin:$PATH"
$ vi ~/.zshrc
export PATH=$HOME/bin:/usr/local/bin:$PATH:/opt/homebrew/anaconda3/bin
. ~/.zshrc
# 아나콘다 설정 초기화
$ which conda
/opt/homebrew/anaconda3/bin
$ conda init zsh
(base) ➜ ~ python --version
Python 3.11.5
(base) ➜ ~ conda create -n lab1
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 23.7.4
latest version: 23.10.0
Please update conda by running
$ conda update -n base -c defaults conda
Or to minimize the number of packages updated during conda update use
conda install conda=23.10.0
## Package Plan ##
environment location: /opt/homebrew/anaconda3/envs/lab1
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: / WARNING conda.core.path_actions:verify(1051): Unable to create environments file. Path not writable.
environment location: /Users/cloudjung/.conda/environments.txt
done
Executing transaction: \ WARNING conda.core.envs_manager:register_env(52): Unable to register environment. Path not writable or missing.
environment location: /opt/homebrew/anaconda3/envs/lab1
registry file: /Users/cloudjung/.conda/environments.txt
done
#
# To activate this environment, use
#
# $ conda activate lab1
#
# To deactivate an active environment, use
#
# $ conda deactivate
conda의 신규 버전이 있어 아래와 같이 update한다.
$ conda update -n base -c defaults conda
$ conda -V
$ conda info
Apple slicon M2 칩을 지원하는 tensorflow를 설치한다. 이떄 conda install과 pip install 명령이 혼동되어 아래 link를 통해 이해했다
conda install 과 pip install의 차이점
conda create -n lab1
conda activate lab1
conda install tensorflow
pip install tensorflow-metal # conda로 하면 못찾음.
conda install jupyterlab
# jupyterlab을 실행한다.
jupyter-lab
cd /opt/homebrew/anaconda3/envs/lab1/lib/python3.11/site-packages
from tensorflow.python.client import device_lib
print("devices : ", device_lib.list_local_devices())
devices : [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
conda env list
conda install jupyter notebook
conda list
conda deactivate
conda remove --name lab1 --all
➜ ~ conda install tensorflow-metal
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
Current channels:
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.