LoginSignup
5
5

More than 1 year has passed since last update.

Apple Silicon M1: conda-forgeのPyTorch (osx-arm64)は遅いぞ。ビルドしようぜ!

Last updated at Posted at 2021-03-14

Update: 2021-12-13 macOS monterey, pytorch0.10.0, torchvision0.11.1

Very slowly

なんでこんなに差がでるんだろ??

time python main.py --num-processes 2 --epoch 2
(あまりにも遅いのでepoch 2で計測)
user system cpu total
build 42.40s 7.50s 258% 19.270
conda-forge 53396.66s 1993.15s 929% 1:39:20.09

これは使い物にならないレベル。自分でビルドしようぜ!!

Environment

  • macOS Monterey 12.0.1 (Apple Silicon M1 Pro MacBook Pro)
  • Miniforge3
conda install numpy matplotlib cython pandas scipy scikit-learn

PyTorch v0.10.0

conda install typing-extensions pyyaml

git clone https://github.com/pytorch/pytorch
cd pytorch
git checkout v1.10.0
git submodule update --init --recursive --depth 1

python setup.py bdist_wheel
pip install bdist/torch-1.10.0a0+git36449ea-cp39-cp39-macosx_12_0_arm64.whl

torchvison v0.11.1

git clone https://github.com/pytorch/vision.git
cd torchvion
git checkout v0.11.1

python setup.py bdist_wheel
pip install dist/torchvision-0.11.0a0+fa347eb-cp39-cp39-macosx_11_0_arm64.whl

Note

ということでIntelと比較。M1速いぜ!

time python main.py --num-processes 4 --epoch 20
user system cpu total
MacBook Air 2020 / Apple Silicon M1 465.06s 79.23s 494% 1:50.05
Mac mini 2019 / Intel Core i5 1071.34s 184.12s 560% 3:44.01
5
5
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5