Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install Tensorflow.io on Mac M1 #1625

Open
sconiac opened this issue Feb 6, 2022 · 83 comments
Open

Cannot install Tensorflow.io on Mac M1 #1625

sconiac opened this issue Feb 6, 2022 · 83 comments

Comments

@sconiac
Copy link

sconiac commented Feb 6, 2022

Hi Im trying to use Tensorflow.io while im learning object detection with this tutorial: https://www.youtube.com/watch?v=yqkISICHH-U&t=9352s and while im training my model I noticed an import of Tensorflow.io but I cannot install it. I try "pip install tenorflow.io" but I get error like:
ERROR: Could not find a version that satisfies the requirement tensorflow.io (from versions: none)
ERROR: No matching distribution found for tensorflow.io

@ZaibanAli
Copy link

I am having the same issue. Did you found something related to this?

@kvignesh1420
Copy link
Member

kvignesh1420 commented Feb 13, 2022

you can install using pip install tensorflow-io. However, please note that the following are different:

import tensorflow as tf
# use tf.io.gfile.listdir(...)
import tensorflow_io as tfio
# use tfio.IODataset.from_audio(...)

The tfio wheels are yet to be built and released for M1 macs though.

@ZaibanAli
Copy link

After running pip install tensorflow-io I get this error:

ERROR: Could not find a version that satisfies the requirement tensorflow-io (from versions: none)
ERROR: No matching distribution found for tensorflow-io

@kvignesh1420
Copy link
Member

@ZaibanAli Since GitHub actions don't support M1 mac based runner environments, we couldn't auto build and publish the tensorflow-io wheels to PyPI for M1 devices. We are working on alternatives to add the support!

@ZaibanAli
Copy link

ZaibanAli commented Feb 13, 2022

I tried to build io myself using python3 setup.py -q bdist_wheel but it gave me this error.

Project: tensorflow-io
Exclude: ['tests', 'tests.*', 'tensorflow_io_gcs_filesystem', 'tensorflow_io_gcs_filesystem.*']
Install Requires: ['tensorflow-io-gcs-filesystem==0.24.0']
Project Rootpath: tensorflow_io
Traceback (most recent call last):
  File "setup.py", line 138, in <module>
    setuptools.setup(
  File "/Users/zaiban.ali/miniforge3/envs/test0/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/Users/zaiban.ali/miniforge3/envs/test0/lib/python3.8/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/zaiban.ali/miniforge3/envs/test0/lib/python3.8/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/Users/zaiban.ali/miniforge3/envs/test0/lib/python3.8/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/zaiban.ali/miniforge3/envs/test0/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 328, in run
    impl_tag, abi_tag, plat_tag = self.get_tag()
  File "/Users/zaiban.ali/miniforge3/envs/test0/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 278, in get_tag
    assert tag in supported_tags, "would build wheel with unsupported tag {}".format(tag)
AssertionError: would build wheel with unsupported tag ('cp38', 'cp38', 'macosx_11_0_arm64')

Reference: #1298 (comment)

@kvignesh1420
Copy link
Member

I think a similar result was posted in #1298 (comment). It would be great to continue the discussion over there as I currently don't have an M1 mac to try things out.

@aelmrabe
Copy link

Hi @kvignesh1420 , I have same issue, I can't install tensorflow-io on Mac m1. Till now, I am only able to install tensorflow-macos and tensorflow-metal successfully. Do you have any update or clue on the issue ? Is it possible to build the tensorflow-io source code from my machine Mac m1 ? If yes which tensorflow-io version I have to take ?

Here the version of tensorflow-deps installed in my machine.

tensorboard 2.8.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow-macos 2.8.0
tensorflow-metal 0.3.0

We really appreciate your help. Many thanks.

@loyio
Copy link

loyio commented Feb 19, 2022

same issues

@invoxiaehu
Copy link

same issue

@sconiac
Copy link
Author

sconiac commented Feb 21, 2022

Ive fix it somehow, i think using wheel help. and then i need to manually change in files downloaded from the tutorial: tensorflow.io to tensorflow-io. It works for me but i'm not sure how exactly i fix it 😄

@ZaibanAli
Copy link

@sconiac can you please tell us in more detail how you did it? I am stuck with this for more than 2 weeks.

@sconiac
Copy link
Author

sconiac commented Feb 22, 2022

I remove my old project, so I create new one by following this tutorial: https://developer.apple.com/metal/tensorflow-plugin/. Then I type:
$ git clone https://github.com/tensorflow/io.git
$ cd io
$ python3 setup.py -q bdist_wheel
Project: tensorflow-io Exclude: ['tests', 'tests.*', 'tensorflow_io_gcs_filesystem', 'tensorflow_io_gcs_filesystem.*'] Install Requires: ['tensorflow-io-gcs-filesystem==0.24.0'] Project Rootpath: tensorflow_io /Users/olivierskonieczny/miniforge3/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn(
(There I get a warning but importing at the end work (also with some weird warnings :) ))

$ python3 -m pip install --no-deps dist/tensorflow_io-0.24.0-cp39-cp39-macosx_11_0_arm64.whl

And last I check if every thing works by:
$ python3
>>> import tensorflow_io as tfio
(its part that throw some error )
>>> print(tfio.__version__)
0.24.0

Hope all works,

@ZaibanAli
Copy link

@sconiac thank you for explaining what you did. I already reached this point but the part where it throws a dynamic library error is the critical one and it is required by Tensorflow object detection api.

@sconiac
Copy link
Author

sconiac commented Feb 22, 2022

Oh, sorry. I didn't notice that, but I'm afraid I don't know how to fix your issue. On my Mac every think works fine, even training my own model. I think you can try old fixing method just reinstall everything you can and that may help.

@dvaldivia
Copy link

Seems like @sconiac steps only works for MacOS 11 not for macOS 12 (Monterey)

@dusskapark
Copy link

same issue

@AntonMaj
Copy link

also got the same issue

@lhayhurst
Copy link

Came here to say, same issue :-)

@wadinj
Copy link

wadinj commented Mar 28, 2022

Same issue aswell

@natehust
Copy link

same issue as well

@JunZhan2000
Copy link

same issue : )

@gabijazdan
Copy link

Same issue, macOS 12 specifically.

@GeoffreyBrunet
Copy link

Same on Mac OS 12 Monterey, with this error:

SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

Any news about compatibility with Apple Silicon please ?

@doncarlos999
Copy link

Same issue (macosx12 m1):

AssertionError: would build wheel with unsupported tag ('cp39', 'cp39', 'macosx_11_0_arm64')

@maxmacstn
Copy link

Same issue on M1 Pro

@sriramk146
Copy link

I recently updated my mac to OS 12.3.1 (M1), I am also facing same issue on installing tensorflow-io. kindly share any, if it can be fixed.

@giacomomiolo
Copy link

Same issue as well

@alexpotv
Copy link

I am also facing the same issue on MacOS 12.3.1, on an M1 Pro 2021 MacBook Pro!

@elia-secchi
Copy link

Same problem here!

@maltequast
Copy link

@sconiac solutions works on macOS 13.0.

@ankitvgupta
Copy link

thanks @dvaldivia - any idea if their PR (google/ml-metadata#166) is mappable to here? I'm not much of a bazel expert but I could poke around.

@piaoziyue
Copy link

same issue

@darrenrahnemoon
Copy link

same issue 🏳️

@nmatare
Copy link

nmatare commented Dec 18, 2022

bump on issue

@qhuang0411
Copy link

same issue

@SuperHao-Wu
Copy link

same issue, any updates?

@surferfelix
Copy link

same issue

@AnasAr96
Copy link

I remove my old project, so I create new one by following this tutorial: https://developer.apple.com/metal/tensorflow-plugin/. Then I type: $ git clone https://github.com/tensorflow/io.git $ cd io $ python3 setup.py -q bdist_wheel Project: tensorflow-io Exclude: ['tests', 'tests.*', 'tensorflow_io_gcs_filesystem', 'tensorflow_io_gcs_filesystem.*'] Install Requires: ['tensorflow-io-gcs-filesystem==0.24.0'] Project Rootpath: tensorflow_io /Users/olivierskonieczny/miniforge3/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( (There I get a warning but importing at the end work (also with some weird warnings :) ))

$ python3 -m pip install --no-deps dist/tensorflow_io-0.24.0-cp39-cp39-macosx_11_0_arm64.whl

And last I check if every thing works by: $ python3 >>> import tensorflow_io as tfio (its part that throw some error ) >>> print(tfio.__version__) 0.24.0

Hope all works,

Worked for me after giving the absolut path to the whl. filed

Thank you

@dusskapark
Copy link

@AnasAr96 ,

I have tried to follow your steps. I successfully passed tensorflow_io installation huddle though, I met another error below. Could you please share your trouble shooting experience for all of us?

ERROR: Cannot install object-detection because these package versions have conflicting dependencies.

The conflict is caused by:
    tf-models-official 2.11.2 depends on tensorflow-text~=2.11.0
    tf-models-official 2.11.0 depends on opencv-python-headless==4.5.2.52
    tf-models-official 2.10.1 depends on tensorflow-text~=2.10.0
    tf-models-official 2.10.0 depends on opencv-python-headless==4.5.2.52
    tf-models-official 2.9.2 depends on tensorflow~=2.9.0
    tf-models-official 2.9.1 depends on tensorflow~=2.9.0
    tf-models-official 2.9.0 depends on tensorflow~=2.9.0
    tf-models-official 2.8.0 depends on tensorflow~=2.8.0
    tf-models-official 2.7.2 depends on tensorflow-text>=2.4.0
    tf-models-official 2.7.1 depends on tensorflow-text>=2.4.0
    tf-models-official 2.7.0 depends on tensorflow>=2.7.0
    tf-models-official 2.6.1 depends on tensorflow-text>=2.6.0
    tf-models-official 2.6.0 depends on tensorflow>=2.5.0
    tf-models-official 2.5.1 depends on tensorflow>=2.5.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

@AnasAr96
Copy link

AnasAr96 commented Jan 15, 2023

@dusskapark ,
you can view it on workaround

B1tstorm/customized_object_detection_system#13

@crueda
Copy link

crueda commented Jan 26, 2023

python3 -m pip install tensorflow-macos
python3 -m pip install tensorflow-metal

@AnasAr96
Copy link

AnasAr96 commented Jan 26, 2023

@crueda

python3 -m pip install tensorflow-macos
python3 -m pip install tensorflow-metal

It is about Tensorflow-io not only Tensorflow

@MATTYGILO
Copy link

Still occurring, any solutions?

@lakhman
Copy link

lakhman commented Mar 28, 2023

The comment/link from AnasAr96 worked for me for the object-detection model from tensorflow (not sure about tensorflow.io), I've included it below (Thanks @AnasAr96):

After a long research I found out that object-detection from tf2 is not compatible on M1 Macs.

but the old version of tf1 would also work without problems.

change your installation to be like:

  • From within TensorFlow/models/research/

cp object_detection/packages/tf1/setup.py .
python -m pip install . --no-deps

So try using tf1:

# Ensure you're in tensorflow/models/research directory
cp object_detection/packages/tf1/setup.py .
python -m pip install . --no-deps

@SidharthArya
Copy link

I guess one solution for now is to

git clone https://github.com/tensorflow/io
cd io
python setup.py build
python setup.py install

@ankitvgupta
Copy link

When I run the above and then import tensorflow_io on my M1 Mac, I now get:

 UserWarning: file system plugins are not loaded: unable to open file: libtensorflow_io.so,

is this the expected behavior? best I can tell the above solutions are not actually installing tensorflow_io on M1 mac yet.

@AndrewKovalenko
Copy link

With the resolution above it seems that some functionality is available and some is not.
After

git clone https://github.com/tensorflow/io
cd io
python setup.py build
python setup.py install

import tensorflow_io as tfio works fine but attempt to use AudioIOTensor crashes:

audio = tfio.audio.AudioIOTensor('gs://cloud-samples-tests/speech/brooklyn.flac')

NotImplementedError: unable to open file: libtensorflow_io.so, from paths: ...

@xplfly
Copy link

xplfly commented Jun 21, 2023

MacBook Air (M1, 2020) version:12.3.1 (21E258)
Here are the steps to resolve this issue:

git clone https://github.com/tensorflow/io
cd io
python setup.py bdist_wheel
cd dist
python -m pip install --no-deps tensorflow_io-0.32.0-cp310-cp310-macosx_11_0_arm64.whl

@gil-mark
Copy link

gil-mark commented Jul 7, 2023

I'm also getting the unable to load libtensorflow_io_plugins.so error that some others have reported above, any idea how to fix this?

@sun1638650145
Copy link

Now, io can be built perfectly on Apple silicon. If anyone needs it, you can find the tutorial here. I hope it can be helpful to everyone.

@yingding
Copy link

yingding commented Sep 9, 2023

I am able to install it directly with

pip install tensorflow-io tensorflow==2.13.0 tensorflow-metal==1.0.1

Now when I run

import tensorflow_io as tfio
audio = tfio.audio.AudioIOTensor('gs://cloud-samples-tests/speech/brooklyn.flac')

I got the error no attribute 'io_audio_readable_init' for AudioIOTensor. Any idea what went wrong?

File [~/VENV/tfio3.10/lib/python3.10/site-packages/tensorflow_io/python/ops/audio_ops.py:671](https://file+.vscode-resource.vscode-cdn.net/Users/yingding/VCS/github/ml/tf-every-day/08Audio/~/VENV/tfio3.10/lib/python3.10/site-packages/tensorflow_io/python/ops/audio_ops.py:671), in AudioIOTensor.__init__(self, filename, dtype)
    669 if not tf.executing_eagerly():
    670     assert dtype is not None, "dtype must be provided in graph mode"
--> 671 resource = core_ops.io_audio_readable_init(filename)
    672 if tf.executing_eagerly():
    673     shape, dtype, rate = core_ops.io_audio_readable_spec(resource)

File [~/VENV/tfio3.10/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:88](https://file+.vscode-resource.vscode-cdn.net/Users/yingding/VCS/github/ml/tf-every-day/08Audio/~/VENV/tfio3.10/lib/python3.10/site-packages/tensorflow_io/python/ops/__init__.py:88), in LazyLoader.__getattr__(self, attrb)
     87 def __getattr__(self, attrb):
---> 88     return getattr(self._load(), attrb)

AttributeError: module '56c055b4afaba95af0256db7c72edd0d967e1981' has no attribute 'io_audio_readable_init'

@AndrewKovalenko
Copy link

AndrewKovalenko commented Sep 15, 2023

@sun1638650145 I followed your guide and installed locally built tensorflow-io

tfio.__version__ // prints '0.34.0'

however I still get unable to open file: libtensorflow_io.so, from paths: ['/Users/labtop/miniconda3/envs/tensorflow-2-13/lib/python3.11/site-packages/tensorflow_io/python/ops/libtensorflow_io.so']
if I try to run

audio = tfio.audio.AudioIOTensor('gs://cloud-samples-tests/speech/brooklyn.flac')

@sid-kap
Copy link

sid-kap commented Sep 15, 2023

FYI there is an Apple Silicon wheel for tensorflow-io 0.34.0 on pypi now
https://pypi.org/project/tensorflow-io/#files

@sun1638650145
Copy link

@AndrewKovalenko This error appears to be caused by a failure to successfully compile libtensorflow_io.so. You can try recompiling it with sudo.

@sun1638650145
Copy link

sun1638650145 commented Sep 15, 2023

@yingding I can reproduce this error as well. This issue is unrelated to the compilation/build process, and someone has already raised a new issue regarding it.

@yingding
Copy link

@sun1638650145 Thanks for linking the issue #1855 (comment), which might be caused by the same root cause of mine. I just opened issue #1859 to track progress.

Are the other features of tfio 0.34.0 usable on M1 besides the AudioIOTensor? or do I need to build manually as workaround.

@eashvere
Copy link

eashvere commented Nov 2, 2023

This worked to get the audio ops compiled on my M1 Mac (Sonoma) with XCode 15 with Tensorflow 2.13 (Python 3.10)

Now, io can be built perfectly on Apple silicon. If anyone needs it, you can find the tutorial here. I hope it can be helpful to everyone.

Although, instead of checking out 0.34, I had to make some adjustments to the build process: https://github.com/eashvere/io

  • Re-adding audio_video_ops to compile on arm64
  • Making sure the swift library compiled to arm64
  • adding a flag to re-enable unary and binary functions (XCode 15 specific)

Didn't test on other devices, older XCodes and other versions of Python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests