Tensorflow on the Mac with an arm64 processor.
Recently I looked at some simple Python scripts to play with TensorFlow. TensorFlow is software created by Google that can be used to create machine learning models. There are libraries for various programming languages. These are needed to apply the models. It is good to know that there are ready-made models that can be downloaded and used.
Of course I wanted to use Ruby. However, I encountered quite high hurdles. So, since in the Machine Learning environment Python is the most used language (not least because of its excellent mathematical libraries), I went ahead with Python. Well … again, there were problems until I understood that the M1 processor on my MacBook was the root of the evil.
After several hours of research I slowly found the right resources. Various tutorials didn’t quite help, but finally Miniconda did the trick to get everything working.
Behind Miniconda is Conda. This is an open source package management system and environment manager for various programming languages such as Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++ and even Fortran (who still uses that?). Miniconda is the little sister of the development environment Anaconda, which is widely used in the Python and ML environment. Just without shi-shi, but only usable on the command line. Who followed my other posts knows that I prefer to do everything via CLI! On the project website you can read:
Miniconda is a free minimal installer for conda. It’s a small bootstrap version of Anaconda that contains only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib, and a few others. Use the conda install command to install 720+ additional conda packages from the anaconda repository.
So, right up my alley.
The install script
The script install-miniconda-tensorflow-mac-arm64.sh
can be found in one of my code repositories on Codeberg can be found. In the end, it’s really just a simple shell script to take the burden off the user of having to painstakingly search for everything together. Currently the versions of the packages tensorflow-macos
are stuck on 2.9
and of tensorflow-metal
on 0.5
. If you want to use newer versions and they exist, you have to change the versions accordingly. I have saved myself to query these (but I should possibly still catch up).
Happy coding!
Zum Weiterlesen
- Get started with tensorflow-metal - Mac OS M1 Tensorflow
- Mask R-CNN - Example Tensorflow application
- Model Garden for TensorFlow - Pretrained Models
- TensorFlow Hub - Pretrained Models