Cannot import Tensorflow Apple M1

I'm trying to use tensorflow, but I can't import it. I followed the steps on the Apple website to download and install Tensorflow, and everything appears to be ok, but when I try to import tensorflow, I get some errors. What should I do?

Errors:

  • TypeError: Unable to convert function return value to a Python type! The signature was () -> handle

  • 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

what I did:

  • conda create --name myenv python
  • conda activate myenv
  • conda install -c apple tensorflow-deps
  • python -m pip install tensorflow-macos
  • python -m pip install tensorflow-metal

conda list:

Thanks, Ed

Replies

You arn't specifying a python version when creating the env. I suspect you may be getting python 3.11, which is likely not yet supported. You can check with python --version Previously python 3.9 was recommended. You can set it when making the env with python=3.9

I had the same issue as you, also using tensorflow-macos 2.10.0 and tensorflow-metal 0.6.0

Installing the previous versions 2.9.2 and 0.5.1 worked though:

conda create --name myenv python conda activate myenv conda install -c apple tensorflow-deps python -m pip install tensorflow-macos==2.9.2 python -m pip install tensorflow-metal==0.5.1

https://pypi.org/project/tensorflow-macos/2.9.2/ https://pypi.org/project/tensorflow-metal/0.5.1/

  • Worked for me as well. Thanks

Add a Comment

Just confirming that python 3.9 and tensorflow-macos==2.9.2 and tensorflow-metal==0.5.1 work for me. Later versions of python and of tensorflow do not. Apple should really make Macs work better with TensorFlow, and update the documentation.