From November 2020, Macbook Air/Macbook Pro/Mac Mini equipped with M1 CPU (Apple Silicon) was released. However, many people may be lamenting the lack of Aarch64 native apps, even if they pull from Macports like a traditional Mac.
This time, I built SciPy and scikit-learn (which doesn't work on Macports) on Python3.8, and it works, so I'll give you a tip.
See @ tenomoto's article Introduction to MacPorts. The method does not change even with the M1 CPU. The location of the file is straightforward
/opt/local
Let's put it in.
Refer to the Hatena blog article How to use homemade ports with MacPorts and set the URL of the local repository in the repository configuration file (here, create the directory "ports" in your home directory. ).
% mkdir ~/ports
% cat /opt/local/etc/macports/sources.conf
....
....
file:///Users/XXX/ports ### <===Newly added###
rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default]
Execute the following command in an appropriate folder.
% git clone https://github.com/gdaisukesuzuki/Macports_tensorflow_macos
Then, a folder called ports is created and folders and files are hung below. This time, you can execute the following command.
(Do not move directory)
% mkdir ~/ports/python
% cp -pr ports/python/py-scipy ~/ports/python/
% cp -pr ports/python/py-scikit-learn ~/ports/python/
% cd ~/ports
% portindex
By executing the last port index, the local repository will be referenced when the command port is executed. Also, py-scipy and py-scikit-learn are registered in the original macports repository, but the one placed locally by this operation has priority.
We will assume that you know how to use the port command. gcc-devel/libgcc-devel Before installation, ld64 and cctools are set as follows in advance.
ld64 @3_3+ld64_xcode
ld64-xcode @2_3
cctools @927.0.2_6+xcode
After that, just install it with port install.
libgcc-devel @11-20210101_0
gcc-devel @11-20210101_0
Python3.8 It is OK to introduce as it is
python38 @3.8.7_0
py38-numpy Before installation, OpenBLAS is set and installed as follows in advance.
OpenBLAS @0.3.13_0+gccdevel+lapack
After that, install it in the following form with port install.
%sudo port install py38-numpy +openblas +gccdevel -gfortran -universal
py38-numpy @1.19.5_0+openblas
py38-scipy Please install in the following form with port install.
%sudo port install py38-scipy +openblas +gccdevel -gfortran -universal
py38-scipy @1.6.0_0+gccdevel+openblas
py38-scikit-learn Please install as follows by port install.
%sudo port install -s -v -d py38-scikit-learn +gcc-devel
py38-scikit-learn @0.24.0_0
This article does not guarantee success in any environment other than the author. ** Build or operation check failure **, (I don't think) ** We are not responsible for any damage to the environment ** (Basically, please do so at your own risk. I think it will be possible).
I have only grasped it softly yet, but part of pytest does not pass, probably because the operation that set the multi-process operation does not work (the parent can not confirm the termination of the sub-process, not the abnormal stop). .. Also, if you run a MacbookAir pytest, the CPU may overheat and take the entire system along with it, causing it to crash.
It depends on OpenBlas in the first place, so I don't use Apple Silicon GPU or Neural Chip at all.
https://github.com/gdaisukesuzuki/Macports_tensorflow_macos ... About homemade Portfile. It also includes settings for installing tensorflow for M1 provided by Apple.
Recommended Posts