Grpcio无法在arm64 Apple Silicon上安装Tensorflow 2.5

gj3fmq9x  于 2022-11-30  发布在  其他
关注(0)|答案(2)|浏览(224)

我是按照这里的指示来做的: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?对我不起作用。
我对架构/芯片挑战相当缺乏经验,但上面写着arm 64目前不受支持?如果是这样的话,那么它被包含在tensorflow_plugin步骤中就很奇怪了。任何关于我做错了什么的想法都将受到赞赏。

eeq64g8w

eeq64g8w1#

帮助我的是:

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

lymgl2op2#

我不得不
1.手动构建boringssl(github答案)
1.在安装grpcio时使用这些标志,如previous answer
1.升级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])))"

相关问题