kornosk / test-pytorch-tensorflow-M1

Code and resources to test training a CNN on M1 macbook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test Pytorch / TensorFlow on M1

Super simple Code and resources to test training a CNN on M1 macbook.

Install PyTorch and TensorFlow for M1

  • PyTorch: see this blog.
  • TensorFlow: see this blog.

Run tests using PyTorch and TensorFlow

1. PyTorch

Run mnist_cnn_pt.py on M1 CPU (GPU not supported yet). Finished in ~6 mins. Results are shown below.

Test set: Average loss: 0.0254, Accuracy: 9919/10000 (99%)
python mnist_cnn.py  903.89s user 331.90s system 306% cpu 6:43.59 total

2. TensorFlow

Run mnist_cnn_tf.py on M1 GPU natively. Finished in ~1 min. Results are shown below.

Test Accuracy: 0.9909000396728516
python mnist_cnn_tf.py  43.96s user 18.72s system 64% cpu 1:37.17 total

My Macbook Spec

  • OS: macOS 12.2.1
  • Model: MacBook Pro (16-inch, 2021)
  • Chip: Apple M1 Pro
  • RAM: 32 GB

More comprehensive evaluations

About

Code and resources to test training a CNN on M1 macbook

License:MIT License


Languages

Language:Python 100.0%