The M1 mac is ready for data science and I can prove it.
Recently I have read the article entitled “I’ll send my M1 Apple back. It’s not ready yet.” which you can find here: https://levelup.gitconnected.com/im-sending-my-m1-apple-back-it-s-not-ready-yet-a4b80f23c6b4. For me, this article looks very biased as most of the things mentioned in this article have an easy fix. In this article, I will try to show my experience with my MacBook Air M1 which I am extensively using for data science and other programming projects.
No, you cannot do all the stuff on M1 which you can do on Intel Mac. You can find a list of compatible software on https://isapplesiliconready.com. What you find there is that most of the applications run Native or through the Rosseta 2. The list of software that I use every day includes Python3, Fortran, Keras, Tensorflow, Docker, node.js, and more.
I bought my Mac on February 2nd and starting from this day I installed all the mentioned software which is working perfectly fine.
Docker and M1
First of all, Docker for M1 is a Tech Preview version. It is not even alpha yet. This means that not everything will work. It is enough to build and run common containers, but don’t expect anything more. Anything more complex I sent to the server where the container is built on an x86 machine. I was aware of this before I bought M1 Mac.
Homebrew
As far as I know, homebrew was working before I bought my Mac (2nd February) and before the mentioned in the introduction article. What I recommend is to install homebrew in x86_64 and arm64 architecture. You can use the following:
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
What I have done is that I installed zsh and added to my .zshrc the following lines
alias ibrew=’arch -x86_64 /usr/local/bin/brew’
alias mbrew=’arch -arm64e /opt/homebrew/bin/brew’
This allows me to easily install packages for Intel and M1 architecture by calling ibrew or mbew respectively. If something is not working with mbrew then I try to install it with ibrew instead.
Broken ZSH after MacOS update
Fix to the problem which also occurred on my Mac after the update and was mentioned in the biased article I used the following command:
xcode-select — install
Everything worked fine after that. This took me like 2 min to repair and the fix was in the first search on google. The post with the fix was there on 7 Feb 2019!
Python
The problems that the author had with python were the main reason why I wrote this post.
Big Sur was released in late 2020, but the default system python, 2.7 is long since deprecated (since 2014) and likely insecure (since sunset in Jan 2020). Less of a problem and more of an observation, really.
This lie. If you run the python command in Terminal you will see this message:
WARNING: Python 2.7 is not recommended. This version is included in macOS for compatibility with legacy software. Future versions of macOS will not include Python 2.7. Instead, it is recommended that you transition to using ‘python3’ from within Terminal.
Second thing is that you should probably not use the included python 3.9.1. If you will use google, you will for sure find that the recommended thing is to use miniforge. I recommend installing everything according to this guide: https://github.com/apple/tensorflow_macos/issues/153. Please use the included env file to install the virtual environment and then the best practice is to set it as a default by including the following line in .zshrc
conda activate name_of_the_virtual_env
This will activate the correct environment every time you start the terminal. Please note that from now on your python will be 3.8.7 as this is the python needed for the M1 version of TensorFlow. Then you can use conda install to install all needed packages. Note that it will use the arm64 version of packages that were compiled for M1 machines. You don’t need to ponder about the following:
Platform detection is causing no end of problems with lots of different libraries; I can’t tell whether it’s
aarch64
,arm64
,arm64/v8
,armv8,armv8.4
or one of a number of other similar things. I suspect the correct one isarm64/v8
(because presumably ARM will want to produce other 64 bit chips at some point!) but the concensus seems to bearm64
and I can foresee lots of problems using a/
character! There is a desperate need for clarification.
Most of the packages work through conda out of the box. Some packages will need compilation. Pandas, scikit-learn, Keras, and TensorFlow work fine, and these are some of the most popular packages used in data science.
GCC, Fortran, Haskell, RStudio, Node.js, and Jupiter
You will need to have GCC compilers and Fortran compiler. As far as I know, GCC is bundled with the env file for TensorFlow. Today (18 Feb 2021) there are two Fortran compilers for M1, one is free and the other is not. The free experimental compiler is located here: https://github.com/fxcoudert/gfortran-for-macOS/releases.
If you have GCC and Fortran compiler working you can now compile and run most of the software natively.
I don’t know Haskell well but I was able to compile a simple HelloWorld.hs program with ghc compiler using ibrew mentioned above. First I installed Haskell-stack ibrew install Haskell-stack then I installed ghci stack ghci and lastly I installed the ghc via ibrew install ghc.
The R Studio was installed via ibrew command and runs well via Rosseta.
The jupyter is working well natively and I was able to test the TensorFlow on my M1. The M1 version of TensorFlow on GPU is only 2–3 times slower than my RTX2060 in training. Given that MBA is a fanless machine this result is quite impressive.
I had no problems with ndoe.js while running it through the Rosseta. The native version is not working for me.
Conclusions
You can run almost anything on M1. I have not yet found a wall with the software I use. There are a lot of native apps like Office365, VS Code Studio which run natively. There are some bugs here and there but bugs are not related to M1 architecture, but the software as general.
My recommendation: If you are unsure or don’t have experience with the terminal and google, or you just want to run the software and not bother with configuration then you should wait till all the software will be ported to M1. But if you have time and will to fix small issues then this is a device for you.
Lastly, please don’t produce fake news. Most of the problems the author of the mentioned article had are because the author refuses to Google things up first, before writing. All of the issues were fixed or had a solution before the article was published. Things that cannot be run natively can be run via Rosseta.