개발

[Apple Silicon] M1 mac 에서 PyTorch 설치

Cho et al. 2022. 6. 4.

1. miniforge 설치 

# By brew
brew install mimiforge


# Or install by wget 

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

bash Miniforge3-MacOSX-arm64.sh

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

 

 

2. conda 환경생성 & torch 설치

# Create env

conda create -n pytorch
conda activate pytorch
conda install python

# install torch

pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu

 

 

3. 설치확인

import torch


torch.device('mps')
# device(type='mps')

torch.__version__
# '1.13.0.dev20220603'

torch.tensor([1,2,3], device="mps")
# tensor([1, 2, 3], device='mps:0')

 

 

 

Reference

Install PyTorch on Apple M1 (M1, Pro, Max) with GPU (Metal) (sudhanva.me)

 

댓글