繁体   English   中英

Grpcio 在 arm64 Apple Silicon 上安装 Tensorflow 2.5 失败

[英]Grpcio fails installation for Tensorflow 2.5 on arm64 Apple Silicon

我按照此处的说明进行操作: https://developer.apple.com/metal/tensorflow-plugin/并且在安装 grpcio 时遇到问题。 当我尝试python -m pip install tensorflow-macos我得到:

  AssertionError: would build wheel with unsupported tag ('cp39', 'cp39', 'macosx_11_0_arm64')
  ----------------------------------------
  ERROR: Failed building wheel for grpcio

随后的尝试也以错误结束:

Running setup.py clean for grpcio
Failed to build grpcio
Installing collected packages: grpcio, tensorflow-estimator, keras-nightly, flatbuffers
  Attempting uninstall: grpcio
    Found existing installation: grpcio 1.38.1
    Uninstalling grpcio-1.38.1:
      Successfully uninstalled grpcio-1.38.1
    Running setup.py install for grpcio ... error

此处给出的解决方案: How can I install GRPCIO on an Apple M1 Silicon laptop? 不幸的是对我没有用。

我对架构/芯片挑战没有经验,但它显示当前不支持 arm64? 如果是这种情况,那么奇怪的是它包含在 tensorflow_plugin 步骤中。 对我做错了什么的任何想法将不胜感激。

对我有帮助的是:

GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1  python -m pip install tensorflow-macos

我不得不

  1. 手动构建boringsslgithub 回答
  2. 如上一个答案中所述,在安装grpcio时使用标志
  3. 升级 numpy( TypeError StackOverflow

安装

# The following are required to locally build boringssl
brew install go
brew install wget
brew install cmake
mkdir boringssl
cd boringssl
wget https://boringssl.googlesource.com/boringssl/+archive/master.tar.gz
gunzip -c master.tar.gz | tar xopf -
mkdir build
cd build
cmake ..
make

# Install `grpcio` with the right 
YCFLAGS="-I /opt/homebrew/opt/openssl/include" LDFLAGS="-L /opt/homebrew/opt/openssl/lib" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install 'grpcio'
pip install tensorflow-macos

# If you see an error like below then upgrade numpy
#
# TypeError: Unable to convert function return value to a Python type! The signature was () -> handle
pip install numpy --upgrade

测试

python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM