I want to do data science with arm64 native python and numpy/scipy/matplotlib, Jupyter-lab etc. on M1 macOS.
At present, if you try to install in the same way as for x86, M1 (arm64) will not compile due to moss etc. (Installed via pip or macports)
For example, there are issues such as altivec
(everyone knows!) The compile flag is not supported by clang and numpy cannot be built.
https://github.com/numpy/numpy/issues/17807
It will be resolved someday, but it's a pain to wait. Building from source is more annoying.
You want to set up an Arm64 native data science environment easily and easily.
miniforge
Apple Silicon, run Scikit-Learn and TensorFlow on the new Macs M1 Run Machine Learning tools natively compiled for Apple Silicon https://towardsdatascience.com/new-apple-silicon-m1-macbook-air-the-dream-laptop-for-machine-learning-engineers-a1590fbd170f
As confirmed in, I use miniforge. It seems that the Arm64 version is originally packaged and maintained for Raspberry Pi etc., so it works fine on M1 as well.
https://github.com/conda-forge/miniforge
Use the arm64 version of the osx installer.
After that, you can use it as a normal (mini) conda.
conda create -n myenv python=3.9
conda activate myenv
Enter the environment as such,
conda install numpy
You can install arm64 as numpy!
Voila! :tada:
It takes a little time to start up at first, but it's taking a long time because it's not Rosetta2 but something else ... shouldn't it?
matplotlib
It worked without any problems.
https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html
Let's run a script that uses numpy/scipy/matplotlib with reference to.
import numpy as np
from scipy.interpolate import interp1d
x = np.linspace(0, 10, num=11, endpoint=True)
y = np.cos(-x**2/9.0)
f = interp1d(x, y)
f2 = interp1d(x, y, kind='cubic')
xnew = np.linspace(0, 10, num=41, endpoint=True)
import matplotlib.pyplot as plt
plt.plot(x, y, 'o', xnew, f(xnew), '-', xnew, f2(xnew), '--')
plt.legend(['data', 'linear', 'cubic'], loc='best')
plt.show()
:tada:
Matplotlib backend error for Mac https://qiita.com/typecprint/items/0d4bea1251ab3f816303
Thank you.
It looks like the default MacOSX
(native?) Backend in miniforge.
If necessary, refer to the link above and edit the matplotlibrc
file to change the backend.
You may also try skipping the screen on the net such as WebAgg
.
Jupyter-lab
https://forum.pine64.org/showthread.php?tid=10299
As you can see, miniforge seems to be recommended in Arm64 environment, and you can install it as it is with conda of miniforge as well!
$ conda activate myenv
$ conda install jupyterlab
All you have to do is start it with jupyter-lab normally!
Ultra super cooooooooooooool!!!!!! :tada:
It will be macports, but it could not be installed because ffmpeg
does not support arm64 for libvpx
.
If you want to make a video using ffmpeg, will it be x86-64 version for a while?
TODO
Recommended Posts