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

Unable to import tfds with tensorflow 2.12 #4858

Closed
rivershah opened this issue Apr 12, 2023 · 12 comments
Closed

Unable to import tfds with tensorflow 2.12 #4858

rivershah opened this issue Apr 12, 2023 · 12 comments
Labels
bug Something isn't working

Comments

@rivershah
Copy link

rivershah commented Apr 12, 2023

Short description
Unable to import tfds

Environment information

  • Operating System:

  • Python version:

  • tensorflow-datasets/tfds-nightly version: tensorflow-datasets==4.9.1

  • tensorflow/tf-nightly version: tensorflow==2.12.0

  • Does the issue still exists with the last tfds-nightly package (pip install --upgrade tfds-nightly) ?

Reproduction instructions

python
Python 3.11.3 (main, Apr  5 2023, 14:15:06) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow_datasets as tfds
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/proto/__init__.py", line 20, in <module>
    from waymo_open_dataset import dataset_pb2 as waymo_dataset_pb2
ModuleNotFoundError: No module named 'waymo_open_dataset'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/__init__.py", line 43, in <module>
    import tensorflow_datasets.core.logging as _tfds_logging
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/__init__.py", line 22, in <module>
    from tensorflow_datasets.core import community
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/community/__init__.py", line 18, in <module>
    from tensorflow_datasets.core.community.huggingface_wrapper import mock_builtin_to_use_gfile
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/community/huggingface_wrapper.py", line 31, in <module>
    from tensorflow_datasets.core import dataset_builder
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/dataset_builder.py", line 34, in <module>
    from tensorflow_datasets.core import dataset_info
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/dataset_info.py", line 52, in <module>
    from tensorflow_datasets.core.features import feature as feature_lib
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/features/__init__.py", line 26, in <module>
    from tensorflow_datasets.core.features.dataset_feature import Dataset
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/features/dataset_feature.py", line 23, in <module>
    from tensorflow_datasets.core.features import sequence_feature
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/features/sequence_feature.py", line 25, in <module>
    from tensorflow_datasets.core.features import features_dict
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/features/features_dict.py", line 26, in <module>
    from tensorflow_datasets.core.features import top_level_feature
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/features/top_level_feature.py", line 24, in <module>
    from tensorflow_datasets.core import example_parser
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/core/example_parser.py", line 30, in <module>
    from tensorflow_datasets.proto import tf_example_pb2
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/proto/__init__.py", line 23, in <module>
    from tensorflow_datasets.proto import waymo_dataset_generated_pb2 as waymo_dataset_pb2  # pylint: disable=line-too-long
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tensorflow_datasets/proto/waymo_dataset_generated_pb2.py", line 130, in <module>
    _descriptor.EnumValueDescriptor(
  File "/usr/local/lib/python3.11/dist-packages/google/protobuf/descriptor.py", line 796, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
@rivershah rivershah added the bug Something isn't working label Apr 12, 2023
@adamdavidcole
Copy link

I'm having the same problem with a lot of students in my class. If anyone finds a workaround, please do share it 🙏 Thanks!

@fineguy
Copy link
Collaborator

fineguy commented Apr 12, 2023

Hi, sorry for the inconvenience, we're working on a fix.

Could you try pip install --force-reinstall -v protobuf==3.20.3?

@cdimofte
Copy link

we got some builds failing due to tensorflow-metadata ( dependency of tensorflow-datasets==4.4.0 ) having had a new version released on 11th April that installed other versions of other packages used by our build

@Wanglongzhi2001
Copy link

I solved it by installing the tfds-nightly and pip install --force-reinstall -v protobuf==3.20.3

@cdimofte
Copy link

I solved it by installing the tfds-nightly and pip install --force-reinstall -v protobuf==3.20.3

yes, this seems to be the workaround

@rivershah
Copy link
Author

rivershah commented Apr 13, 2023

Unfortunately this is not a great workaround. protobuf needs to be on later versions for many other parts of the more recent tensorflow ecosystem. Requesting that we please fix this issue in tfds with tensorflow>=2.12.0

@andreped
Copy link
Contributor

I have the same problem wth tensorflow==2.10.

I believe the correct fix would be to change the protobuf versioning set here to protobuf<=3.20

At least that resolved the issue for me in the GradientAccumulator project.

@fineguy
Copy link
Collaborator

fineguy commented Apr 13, 2023

We published a new release, could you please confirm that it works for you?
pip install tensorflow_datasets==4.9.2 --upgrade

@coreyfournier
Copy link

We published a new release, could you please confirm that it works for you? pip install tensorflow_datasets==4.9.2 --upgrade
@fineguy Works for me

@fineguy fineguy closed this as completed Apr 13, 2023
@beew
Copy link

beew commented Apr 24, 2023

We published a new release, could you please confirm that it works for you? pip install tensorflow_datasets==4.9.2 --upgrade

No, it doesn't work.

pip install tensorflow_datasets==4.9.2 --upgrade --dry-run
...
Would install protobuf-4.22.3 tensorflow-datasets-4.9.2 tensorflow-metadata-1.13.1

tensorfow-2.11.0 requires protobuf<3.20,>=3.9.2

@Laubeee
Copy link

Laubeee commented May 19, 2023

I'm on tf 2.10 (for cuda on windows) and solved it by installing tf-metadata 1.13.0 first, which does not need newer protobuf. Then, I used an old version of tf-datasets which also does not need newer protobuf.

so it was:

pip install tensorflow-metadata==1.13.0 
pip install tensorflow_datasets==4.4.*

@Laubeee
Copy link

Laubeee commented May 19, 2023

so tf datasets could in theory solve this by changing its requirements to tf-metadata <= 1.13.0 for its older versions such that the protobuf-requirements align in the end

and then perhaps it can even be made so when you just pip install the package it will choose the right one for the installed tf version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants