tensorflow: tflite-model-maker cannot be installed correctly for different reasons on different configurations

If you try to install tflite-model-maker-nightly basically it starts to download all nightly build wheels since the first release rather than latest one as supposed.

This seems caused by a bad configuration. Many people have reported this issue many months ago, it remained unsolved as this other issue.

But they aren’t the only setup issues that affects tflite-model-maker.

If you try to install the latest build with pip install tflite-model-maker it raises various errors e.g. tflite-support dependency that hasn’t any wheel available in repository (for windows since the 0.4.0 released in May 2022 there is no wheel at all and the latest is 0.3.1 that has no wheel for latest Python versions).

Tried on Linux arm64 and needed wheels are missing too.

How is decided to upgrade version dependencies requirements without release updated dependencies coherently, considering these are developed by same company?

If it isn’t followed a coherent path, it is obvious that troubles arise and you have to waste time trying to find if there is a combination of OS type, architecture, Python version, package version, dependency version, that may work, digging in the repository release history and requirements.

tflite-model-maker has been released a couple of years ago to simplify model training and it was very good at this, before the project maintenance started to become erratic and lackluster creating a lot of compatibility issues and conflicts.

Is this project development still active?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 16 (1 by maintainers)

Most upvoted comments

I can confirm that installing either the TfLite Model Maker or the MediaPipe one fails using Python v3.11.5 on a Mac M1 for multiple users in our company. @pkgoogle you guys keep saying in multiple GitHub issues that this is actively worked upon, but:

  1. There are at least 5 active issues in this repository apart from this one, with even twice as many closed ones. At this point you should probably ask yourselves, if so many people report issues with the installation process, maybe there actually is an issue and thus the process should be improved and/or better documented? image
  2. Not even the “new kid on the block” MediaPipe works. If you guys keep releasing new software, even though the old one isn’t working correctly, how will that help the community?

I’m sorry, but at this point, it’s a very valid question if the project development is still active. Do you guys even test out if the tools work? Like, seriously. Get a fresh new laptop and try to install either of the 2 model makers following the official tutorial.

On the subject of mediapipe-model-maker this reply points to an announcement from the Tensorflow Text team stating that wheels will be provided only for Linux x86_64 and Intel-based Macs (mediapipe-model-maker depends on tensorflow-text at present).

The recommended solution is to build wheels for the desired platform from source yourself.

Moreover, quoting from the announcement

Note that TF Text needs to be built in the same environment as TensorFlow. Thus, if you manually build TF Text, it is highly recommended that you also build TensorFlow.

I fully empathise with @bogdanzurac’s frustration! Arm64-based Macs are not bleeding-edge hardware anymore, and the fact that this issue still persist is IMO pretty embarrassing for the team responsible for these tools.

I’ll try to summarise the approaches I have tried and my findings, in the hope that someone (@pkgoogle perhaps?) might take appropriate actions or provide constructive hints for how to move this forward.

Installing with Python 3.11 on MacOs with Arm64 (native environment) fails on tflite-support

The conflict is caused by:
    tflite-model-maker 0.4.2 depends on tflite-support>=0.4.2
    tflite-model-maker 0.4.1 depends on tflite-support-nightly
    :
    : 

Latest version of tflite-support at time of writing (linked above) provides wheels for Linux/Arm64 and MacOs/x86_64, but not the combo MacOs/Arm64. Python 3.11 is not the issue in this case, ref list of wheels in link above.

  • tflite-support is built using Bazel, with which I’m not familiar. I might spend some time later to understand Bazel and try to build tflite-support for MacOs/Arm64. Any constructive hints are greatly appreciated (not links to the manual - I’m able to find that myself 😉 )

Given that tflite-support is provided for MacOs/x86_64, it’s tempting to lean on Rosetta and install x86_64 versions of everything. However, scrolling a little down on the linked page reveals that AVX-instructions are not translated by Rosetta. Furthermore, this issue indicates that QEMU/Docker may not come to the rescue here either. Since Tensorflow seems to rely heavily on AVX the approach of using x86_64 binaries seems to be unfruitful.

Last possibility I see on my M1 is to try wheels for Linux/Arm64 with some Arm64-based Linux like e.g. python:3.9-bullseye running in Docker:

MacBook-Air:bjarne$ docker run -it --rm python:3.9-bullseye bash
root@9656157ee22e:/# arch
aarch64
root@9656157ee22e:/#

(NOTE: The option --use-deprecated=legacy-resolver to pip is crucial in next step - wish the docs were clearer on this. See e.g. this issue.)

root@ 9656157ee22e:/# pip install --use-deprecated=legacy-resolver tflite-model-maker
Collecting tflite-model-maker
  Downloading tflite_model_maker-0.4.2-py3-none-any.whl (577 kB) 
  : 
  : 
ERROR: Could not find a version that satisfies the requirement tensorflow-addons>=0.11.2 (from tflite-model-maker) (from versions: none)
ERROR: No matching distribution found for tensorflow-addons>=0.11.2 (from tflite-model-maker)

Looking up wheels for tensorflow-addons on pypi we see that there is indeed no wheel for Linux/Arm64. Ironically, there are wheels for MacOs/Arm64… 🤦 Moreover, adding insult to injury, tensorflow-addons will be discontinued in a year or so.

sigh

Installing mediapipe-model-maker (aka “new kid on the block”) on MacOs/Arm64 fails because tensorflow-text==2.13.0 has no wheel for the platform

MacBook-Air:bjarne$ pip install mediapipe-model-maker
  : 
  : 
ERROR: Cannot install mediapipe-model-maker because these package versions have conflicting dependencies.

The conflict is caused by:
    tf-models-official 2.13.2 depends on tensorflow-text~=2.13.0
  : 
  : 

Installing the mediapipe-model-maker in Linux/Arm64 under Docker bumps into the problem with tensorflow-addons

root@9656157ee22e:/# pip install mediapipe-model-maker
Collecting mediapipe-model-maker
  Downloading mediapipe_model_maker-0.2.1.3-py3-none-any.whl (127 kB)
  : 
  : 
ERROR: Cannot install mediapipe-model-maker==0.1.0.2, mediapipe-model-maker==0.1.1.0, mediapipe-model-maker==0.1.1.1, mediapipe-model-maker==0.2.1, mediapipe-model-maker==0.2.1.1, mediapipe-model-maker==0.2.1.2 and mediapipe-model-maker==0.2.1.3 because these package versions have conflicting dependencies.

The conflict is caused by:
    mediapipe-model-maker 0.2.1.3 depends on tensorflow-addons
    mediapipe-model-maker 0.2.1.2 depends on tensorflow-addons
  : 
  : 

Hence, on an Arm-based Mac trying to use tflite-model-maker I’m stuck until either

  1. tflite-support provides wheel for MacOs/Arm64
  2. tensorflow-addons provides wheel for Linux/Arm64 (requires QEMU/Docker)

and trying to use mediapipe-model-maker I’m stuck until either

  1. tensorflow-text==2.13.0 provides wheel for MacOs/Arm64
  2. tensorflow-addons provides wheel for Linux/Arm64 (requires QEMU/Docker)

yes, images.

Hi @BjarneHerland, it is probably best to post those issues on the mediapipe github issues page: https://github.com/google/mediapipe/issues, I tried a couple of things it seems python=3.10 works best. I was able to install with python=3.10 successfully on linux x86_64. It might be worth it to try on linux ARM. Using colab is probably the most stable currently. I am running into a different issue for my mac M1. :

Collecting pyyaml<6.0,>=5.1 (from tf-models-official==2.11.6->mediapipe-model-maker)
  Using cached PyYAML-5.4.1.tar.gz (175 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [62 lines of output]
      /private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
      !!
      
              ********************************************************************************
              The license_file parameter is deprecated, use license_files instead.
      
              By 2023-Oct-30, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.
      
              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************
      
      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      running egg_info
      writing lib3/PyYAML.egg-info/PKG-INFO
      writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt
      writing top-level names to lib3/PyYAML.egg-info/top_level.txt
      Traceback (most recent call last):
        File "/Users/xxxxxx/miniforge3/envs/mediapipe_model_maker/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/xxxxxx/miniforge3/envs/mediapipe_model_maker/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/xxxxxxx/miniforge3/envs/mediapipe_model_maker/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in run_setup
          exec(code, locals())
        File "<string>", line 271, in <module>
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 989, in run_command
          super().run_command(command)
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 318, in run
          self.find_sources()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 326, in find_sources
          mm.run()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 548, in run
          self.add_defaults()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/command/egg_info.py", line 586, in add_defaults
          sdist.add_defaults(self)
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/command/sdist.py", line 113, in add_defaults
          super().add_defaults()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults
          self._add_defaults_ext()
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
        File "<string>", line 201, in get_source_files
        File "/private/var/folders/q_/v3c1qs3n1z56cfpxr_5v3p1w0148zx/T/pip-build-env-ye44j30y/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

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