Grpcio fails installation for Tensorflow 2.5 on arm64 Apple Silicon

2.9k views Asked by At

I'm following the instructions here: https://developer.apple.com/metal/tensorflow-plugin/ and having issues installing grpcio. When I try python -m pip install tensorflow-macos I get:

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

The subsequent attempt also ends in an error:

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

The solutions given here: How can I install GRPCIO on an Apple M1 Silicon laptop? have unfortunately not worked to me.

I am quite inexperienced with architecture/chip challenges, but it reads that the arm64 is currently not supported? If that is the case it is odd that it is included in the tensorflow_plugin steps. Any thoughts on what I am doing wrong would be appreciated.

2

There are 2 answers

0
Vishnu PS On

I had to

  1. Build boringssl manually (github answer)
  2. Use the flags while installing grpcio as explained in the previous answer
  3. Upgrade numpy (TypeError StackOverflow)

Install

# 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

Test

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

What helped me was:

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