笔者在调试Tacotron2官模时,调取tensorflow时出现了这样的错误。
Traceback (most recent call last):
File "M:/project/project/TTS/Offical_model/Tacotron2/tacotron2/junk/test/torch_version_test.py", line 8, in <module>
import tensorflow
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow\__init__.py", line 99, in <module>
from tensorflow_core import *
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "<frozen importlib._bootstrap>", line 1019, in _handle_fromlist
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "M:\project\env\anaconda\env\Tacotron2\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\core\framework\graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\core\framework\node_def_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\core\framework\attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\core\framework\tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\core\framework\resource_handle_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\tensorflow_core\core\framework\tensor_shape_pb2.py", line 42, in <module>
serialized_options=None, file=DESCRIPTOR),
File "M:\project\env\anaconda\env\Tacotron2\lib\site-packages\google\protobuf\descriptor.py", line 560, 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
显而易见,问题原因:
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.
再加上建议处理方法:
1. Downgrade the protobuf package to 3.20.x or lower.
所以这个地方直接pip install protobuf==3.20
.
笔者的版本是4.21.12,在重新安装protobuf后解决了问题,在此之前也是因为tensorflow版本的问题重新将cuda版本从12降为了10.2。
文章出处登录后可见!
已经登录?立即刷新