From 6bb2708ccdf1714a94cf975a9cefae322d22d213 Mon Sep 17 00:00:00 2001 From: risemeup1 <515586620@qq.com> Date: Mon, 20 Feb 2023 11:53:02 +0000 Subject: [PATCH] fix _message of protobuf --- .../paddle/distributed/fleet/base/distributed_strategy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/paddle/distributed/fleet/base/distributed_strategy.py b/python/paddle/distributed/fleet/base/distributed_strategy.py index fbe391b45f055..32785a084f201 100755 --- a/python/paddle/distributed/fleet/base/distributed_strategy.py +++ b/python/paddle/distributed/fleet/base/distributed_strategy.py @@ -22,6 +22,12 @@ from paddle.fluid.framework import _global_flags from paddle.fluid.wrapped_decorator import wrap_decorator +protobuf_version = google.protobuf.__version__ +if protobuf_version >= "4.21.0": + import google._upb._message as _message +else: + import google.protobuf.pyext._message as _message + __all__ = [] non_auto_func_called = True @@ -2497,7 +2503,7 @@ def __repr__(self): for ff in config_fields: if isinstance( getattr(my_configs, ff.name), - google.protobuf.pyext._message.RepeatedScalarContainer, + _message.RepeatedScalarContainer, ): values = getattr(my_configs, ff.name) for i, v in enumerate(values):