apple-m1-tensflow

mac 终端下,执行以下命令,即可安装brew:
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

参考
https://github.com/conda-forge/miniforge/#download
https://github.com/apple/tensorflow_macos/releases/tag/v0.1alpha1
https://claytonpilat.medium.com/tutorial-tensorflow-on-an-m1-mac-using-jupyter-notebooks-and-miniforge-dbb0ef67bf90

 

brew 提示错误 fatal: Could not resolve HEAD to a revision 
解决方式参考:
git -C $(brew --repository homebrew/core) checkout master
git -C $(brew --repository homebrew/core) reset --hard HEAD.

1. 安装docker

1.1 下载,打开,拖到 Application

MacM1# softwareupdate –install-rosetta
https://docs.docker.com/desktop/mac/apple-silicon/

1.2 [Google] docker for mac更换国内镜像源

https://blog.csdn.net/w605283073/article/details/105061455
https://docker.mirrors.ustc.edu.cn
https://hub-mirror.c.163.com

1.3 【Docker】
MacM1# docker run -d –privileged=true –name=armpy37_v2 -it arm64v8/python:3.7-bullseye bash

#docker虚拟机内运行
armpy37#

cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
sed -i “s@http://ftp.debian.org@https://repo.huaweicloud.com@g” /etc/apt/sources.list
sed -i “s@http://deb.debian.org@https://repo.huaweicloud.com@g” /etc/apt/sources.list
sed -i “s@http://security.debian.org@https://repo.huaweicloud.com@g” /etc/apt/sources.list

apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-get install -y python3-tables-dbg python3-tables-lib
apt-get install -y r-bioc-hdf5array r-bioc-rhdf5 r-bioc-rhdf5filters r-bioc-rhdf5lib
apt-get install -y r-cran-hdf5 r-cran-hdf5r vitables libhdf5-dev libhdf5-103 hdf5-tools h5utils hdf5-helpers
apt-get install -y xmpi openmpi-bin libxmpi4-dev mpi-default-dev libhdf5-openmpi-dev libhdf5-mpi-dev
apt-get install -y cmake

pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple
pip config set global.trusted-host repo.huaweicloud.com

pip install stable-baselines
pip install versioned-hdf5

wget https://repo.rock-chips.com/pypi/simple/tensorflow/tensorflow-1.14.0-cp37-none-linux_aarch64.whl
pip install tensorflow-1.14.0-cp37-none-linux_aarch64.whl

cd /usr/local/lib/python3.7/site-packages/tensorflow/contrib/ && cp __init__.py __init__.py.backup
sed -i ‘s/if os.name/#if os.name/g’ /usr/local/lib/python3.7/site-packages/tensorflow/contrib/__init__.py
sed -i ‘s/from tensorflow.contrib import cloud/#from tensorflow.contrib import cloud/g’ /usr/local/lib/python3.7/site-packages/tensorflow/contrib/__init__.py

cd /dev/shm/ && wget https://apnode.win/cd/TestFPS.zip
cd /dev/shm/ && unzip TestFPS.zip && python TestFPS.PY

 
brew install fftw
brew install openblas
OPENBLAS=”$(brew –prefix openblas)” pip install numpy pandas
$ brew install python@3.9
$ brew install openblas
$ OPENBLAS=”$(brew –prefix openblas)” MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install cython –no-use-pep517
$ OPENBLAS=”$(brew –prefix openblas)” MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install numpy –no-use-pep517
$ OPENBLAS=”$(brew –prefix openblas)” MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install pandas –no-use-pep517
$ OPENBLAS=”$(brew –prefix openblas)” MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install pybind11 –no-use-pep517
$ OPENBLAS=”$(brew –prefix openblas)” MACOSX_DEPLOYMENT_TARGET=11.1 python3 -m pip install scipy –no-use-pep517
$ brew install libjpeg zlib
$ python3 -m pip install pillow
$ python3 -m pip install matplotlib
OPENBLAS=”$(brew –prefix openblas)” pip install numpy
 
OPENBLAS=”$(brew –prefix openblas)” pip install scipy

brew install pkg-config
brew install openblas gfortran
brew install hdf5
export OPENBLAS=/opt/homebrew/opt/openblas/lib/

https://stackoverflow.com/questions/65745683/how-to-install-scipy-on-apple-silicon-arm-m1

pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple
pip config set global.extra-index-url https://repo.rock-chips.com/pypi/simple

arch -x86_64 /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”