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

DeprecationWarning from google.protobuf #68194

Closed
lazarust opened this issue May 18, 2024 · 8 comments
Closed

DeprecationWarning from google.protobuf #68194

lazarust opened this issue May 18, 2024 · 8 comments
Assignees
Labels
comp:apis Highlevel API related issues stat:awaiting response Status - Awaiting response from author TF 2.16 type:bug Bug

Comments

@lazarust
Copy link

lazarust commented May 18, 2024

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

tf 2.16.1

Custom code

Yes

OS platform and distribution

MacOS 14.4.1

Mobile device

No response

Python version

3.12.2

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

When running a pytest that import tensorflow, I get the following DeprecrecationWarnings:

  • Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14
  • Type google._upb._message.ScalarMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14

Standalone code to reproduce the issue

Since this happens specifically in a `pytest` and not when importing tensorflow via the shell I'm unsure how to replicate this, but I've attached the traceback.

Relevant log output

import tensorflow as tf
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/__init__.py:47: in <module>
    from tensorflow._api.v2 import __internal__
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/_api/v2/__internal__/__init__.py:8: in <module>
    from tensorflow._api.v2.__internal__ import autograph
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/_api/v2/__internal__/autograph/__init__.py:8: in <module>
    from tensorflow.python.autograph.core.ag_ctx import control_status_ctx # line: 34
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/python/autograph/core/ag_ctx.py:21: in <module>
    from tensorflow.python.autograph.utils import ag_logging
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/python/autograph/utils/__init__.py:17: in <module>
    from tensorflow.python.autograph.utils.context_managers import control_dependency_on_returns
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/python/autograph/utils/context_managers.py:19: in <module>
    from tensorflow.python.framework import ops
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/python/framework/ops.py:33: in <module>
    from tensorflow.core.framework import attr_value_pb2
../../../.virtualenvs/skops/lib/python3.12/site-packages/tensorflow/core/framework/attr_value_pb2.py:5: in <module>
    from google.protobuf.internal import builder as _builder
../../../.virtualenvs/skops/lib/python3.12/site-packages/google/protobuf/internal/builder.py:18: in <module>
    from google.protobuf.internal import python_message
../../../.virtualenvs/skops/lib/python3.12/site-packages/google/protobuf/internal/python_message.py:36: in <module>
    from google.protobuf import descriptor as descriptor_mod
../../../.virtualenvs/skops/lib/python3.12/site-packages/google/protobuf/descriptor.py:17: in <module>
    from google.protobuf.internal import api_implementation
../../../.virtualenvs/skops/lib/python3.12/site-packages/google/protobuf/internal/api_implementation.py:51: in <module>
    if _CanImport('google._upb._message'):
../../../.virtualenvs/skops/lib/python3.12/site-packages/google/protobuf/internal/api_implementation.py:41: in _CanImport
    mod = importlib.import_module(mod_name)
../../../.pyenv/versions/3.12.2/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   SystemError: <class 'DeprecationWarning'> returned a result with an exception set
_______________________________________________________________________________________________________________________________________ ERROR collecting skops/io/tests/test_visualize.py ________________________________________________________________________________________________________________________________________
DeprecationWarning: Type google._upb._message.MessageMapContainer uses PyType_Spec with a metaclass that has custom tp_new. This is deprecated and will no longer be allowed in Python 3.14.```
@google-ml-butler google-ml-butler bot added the type:bug Bug label May 18, 2024
@lazarust lazarust changed the title DeprecationWarning in google.protobuf DeprecationWarning from google.protobuf May 20, 2024
@sushreebarsa sushreebarsa added comp:apis Highlevel API related issues TF 2.16 labels May 20, 2024
@sushreebarsa
Copy link
Contributor

@lazarust Could you consider explicitly upgrading protobuf. You can find compatible versions on the official protobuf website here. Kindly refer to this issue as well for more information.
Thank you!

@sushreebarsa sushreebarsa added the stat:awaiting response Status - Awaiting response from author label May 20, 2024
@lazarust
Copy link
Author

lazarust commented May 21, 2024

Thanks for the response @sushreebarsa. I tried upgrading protobuf by running pip install -U protobuf and still get the same deprecation warning with protobuf 5.26.1.

Is there something else I should do/could try?

It also looks like tensorflow requires a version of protobuf that's < 5.0.0. Is 5.0 + support something that could be updated?

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label May 21, 2024
@sushreebarsa
Copy link
Contributor

@lazarust The error you're encountering is related to a deprecation warning in protobuf and its incompatibility with TensorFlow in your current environment. Kindly ensure you're upgrading protobuf and TensorFlow within the same virtual environment you're using for your project. This avoids conflicts with other projects that might have different dependency requirements. Another workaround could be downgrading protobuf to a version below 5.0.0 which is not ideal.
TensorFlow is yet to fully support protobuf versions above 5.0.

Thank you!

@sushreebarsa sushreebarsa added the stat:awaiting response Status - Awaiting response from author label May 21, 2024
@lazarust
Copy link
Author

@sushreebarsa I've verified that I'm using tensorflow 2.16.1 and protobuf 4.25.3 (this is the newest protobuf supported by tensorflow from what I can tell). I'm still running into the DeprecationWarnings.

If it's not an easy fix since tensorflow doesn't support protobuf 5.0+, we can ignore those warnings for now. Unless you have a better idea?

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label May 22, 2024
@sushreebarsa
Copy link
Contributor

Hi, @lazarust ! Ignoring the warnings might seem like a quick solution. If downgrading protobuf or upgrading TensorFlow is not feasible, you can suppress the warnings.

import warnings
warnings.filterwarnings("ignore", message=".*DeprecationWarning.*")


Please find the doc here which has the supported protobuf versions mentioned in it. Kindly stay updated with TF releases.

Thank you!

@lazarust
Copy link
Author

@sushreebarsa We've decided to just suppress the warnings for now until TensorFlow supports the new version of protobuf. Should I close this issue?

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Status - Awaiting response from author label May 25, 2024
@sushreebarsa
Copy link
Contributor

@lazarust Sure, you could move this issue to close status for now and stay updated for new releases. Thank you!

@sushreebarsa sushreebarsa added the stat:awaiting response Status - Awaiting response from author label May 27, 2024
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:apis Highlevel API related issues stat:awaiting response Status - Awaiting response from author TF 2.16 type:bug Bug
Projects
None yet
Development

No branches or pull requests

2 participants