There are some installation problems such as 'official tensorflow-metal'.

System information

  • OS Platform and Distribution: macOS 13.3.1 (MacBook Pro M2)
  • Python Version(Default): Python 3.11.3

Official Installation Guide: https://developer.apple.com/metal/tensorflow-plugin/

  • I just followed the installation guide.
(base) haesunglee@MacBookPro14-haesunglee ~ % python3 -c 'import tensorflow as tf; print(tf.__version__)
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
Traceback (most recent call last):
  File "/Users/haesunglee/tensorflow_metal.py", line 1, in <module>
    import tensorflow as tf
  File "/Users/haesunglee/miniconda/lib/python3.10/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/Users/haesunglee/miniconda/lib/python3.10/site-packages/tensorflow/python/__init__.py", line 42, in <module>
    from tensorflow.python import data
  File "/Users/haesunglee/miniconda/lib/python3.10/site-
    from tensorflow.python.data.experimental.ops.data_service_ops import distribute
  File "/Users/haesunglee/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 22, in ...
...
...
...
packages/tensorflow/python/framework/sparse_tensor.py", line 25, in <module>
    from tensorflow.python.framework import constant_op
  File "/Users/haesunglee/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/constant_op.py", line 25, in <module>
    from tensorflow.python.eager import execute
  File "/Users/haesunglee/miniconda/lib/python3.10/site-packages/tensorflow/python/eager/execute.py", line 21, in <module>
    from tensorflow.python.framework import dtypes
  File "/Users/haesunglee/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/dtypes.py", line 37, in <module>
    _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type()
TypeError: Unable to convert function return value to a Python type! The signature was
	() -> handle
(base) haesunglee@MacBookPro14-haesunglee ~ % 
(base) haesunglee@MacBookPro14-haesunglee ~ %

Accepted Reply

Thank you for helping it but I'm still struggling about installing tflite-model-maker. Let's have a look.

System information

OS Platform and Distribution: macOS 13.3.1 (MacBook Pro M2) tensorflow-macos Version: 2.12.0 tensorflow-metal Version: 0.8.0 Python Version: Python 3.9.16 Pip versions: pip 23.0.1 from /Users/haesunglee/miniconda/lib/python3.9/site-packages/pip (python 3.9) TensorFlow Version: 2.12.0 numpy Version: 1.24.3 My log: haesunglee@MacBookPro14-haesunglee ~ % haesunglee@MacBookPro14-haesunglee ~ % sudo pip3 install tflite-model-maker Password: WARNING: The directory '/Users/haesunglee/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. Collecting tflite-model-maker Downloading tflite_model_maker-0.4.2-py3-none-any.whl (577 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 577.3/577.3 kB 12.6 MB/s eta 0:00:00 Collecting librosa==0.8.1 Downloading librosa-0.8.1-py3-none-any.whl (203 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 203.8/203.8 kB 12.1 MB/s eta 0:00:00 Collecting lxml>=4.6.1 ... ... ... INFO: pip is looking at multiple versions of sentencepiece to determine which version is compatible with other requirements. This could take a while. Collecting sentencepiece Downloading sentencepiece-0.1.98-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 2.1 MB/s eta 0:00:00 Downloading sentencepiece-0.1.97-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 2.5 MB/s eta 0:00:00 Downloading sentencepiece-0.1.96.tar.gz (508 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.6/508.6 kB 1.4 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Downloading sentencepiece-0.1.95.tar.gz (508 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.7/508.7 kB 2.1 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Downloading sentencepiece-0.1.94.tar.gz (507 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 507.5/507.5 kB 2.5 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Downloading sentencepiece-0.1.91.tar.gz (500 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 500.5/500.5 kB 2.6 MB/s eta 0:00:00 **Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [2 lines of output] /bin/sh: pkg-config: command not found Failed to find sentencepiece pkgconfig [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.** haesunglee@MacBookPro14-haesunglee ~ %

Replies

Hi @StephenLee,

Looks like your numpy version is incompatible with the TensorFlow version you are trying to install, can you try updating it, please? python3 -m pip install numpy --upgrade

  • I have done it but still struggling.

Add a Comment

Thank you for helping it but I'm still struggling about installing tflite-model-maker. Let's have a look.

System information

OS Platform and Distribution: macOS 13.3.1 (MacBook Pro M2) tensorflow-macos Version: 2.12.0 tensorflow-metal Version: 0.8.0 Python Version: Python 3.9.16 Pip versions: pip 23.0.1 from /Users/haesunglee/miniconda/lib/python3.9/site-packages/pip (python 3.9) TensorFlow Version: 2.12.0 numpy Version: 1.24.3 My log: haesunglee@MacBookPro14-haesunglee ~ % haesunglee@MacBookPro14-haesunglee ~ % sudo pip3 install tflite-model-maker Password: WARNING: The directory '/Users/haesunglee/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. Collecting tflite-model-maker Downloading tflite_model_maker-0.4.2-py3-none-any.whl (577 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 577.3/577.3 kB 12.6 MB/s eta 0:00:00 Collecting librosa==0.8.1 Downloading librosa-0.8.1-py3-none-any.whl (203 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 203.8/203.8 kB 12.1 MB/s eta 0:00:00 Collecting lxml>=4.6.1 ... ... ... INFO: pip is looking at multiple versions of sentencepiece to determine which version is compatible with other requirements. This could take a while. Collecting sentencepiece Downloading sentencepiece-0.1.98-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 2.1 MB/s eta 0:00:00 Downloading sentencepiece-0.1.97-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 2.5 MB/s eta 0:00:00 Downloading sentencepiece-0.1.96.tar.gz (508 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.6/508.6 kB 1.4 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Downloading sentencepiece-0.1.95.tar.gz (508 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 508.7/508.7 kB 2.1 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Downloading sentencepiece-0.1.94.tar.gz (507 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 507.5/507.5 kB 2.5 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Downloading sentencepiece-0.1.91.tar.gz (500 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 500.5/500.5 kB 2.6 MB/s eta 0:00:00 **Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [2 lines of output] /bin/sh: pkg-config: command not found Failed to find sentencepiece pkgconfig [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.** haesunglee@MacBookPro14-haesunglee ~ %