如果是普通的Intel CPU的Mac,安装一个onnxruntime很简单,直接
pip3 install onnxruntime
一行命令就可以搞定。
但是因为是M1版,很多东西模式是不支持的,需要一个个坑踩过去。
安装基础工具
brew install automake libtool autoconf
安装protoc
下载源码 https://codeload.github.com/protocolbuffers/protobuf/zip/refs/tags/v21.1并解压
cd protobuf-21.1
./autogen.sh
make -j4
sudo make install
protoc --version
安装onnxruntime
git clone https://github.com/microsoft/onnxruntime.git
cd onnxruntime
./build.sh --config Release --osx_arch arm64 --osx_arch arm64 --build_wheel --enable_pybind --parallel --use_coreml --use_extensions --skip_tests --build_shared_lib
编译好之后安装whl包
pip3 install -U ./build/MacOS/Release/dist/onnxruntime-1.12.0-cp39-cp39-macosx_12_0_arm64.whl
之后就可以正常使用了