【发布时间】:2022-06-11 03:46:35
【问题描述】:
我已经安装和设置 GPU 版本的 tensorflow 大约 8 个小时了。我终于把所有东西都安装好了,但是当我尝试测试它时,我得到了这个错误:
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\eager\context.py", line 32, in <module>
from tensorflow.core.framework import function_pb2
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\core\framework\function_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 "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\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 "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\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 "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\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 "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\core\framework\tensor_shape_pb2.py", line 36, in <module>
_descriptor.FieldDescriptor(
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38\lib\site-packages\google\protobuf\descriptor.py", line 560, in __new__
return _message.default_pool.FindFieldByName(full_name)
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
我会把我的安装设置放在下面以供参考:
- 张量流 2.3.0
- Python 3.8.10
- CUDA 10.1
- cuDNN 7.6
- 操作系统:Windows 10
【问题讨论】:
-
请提供足够的代码,以便其他人更好地理解或重现问题。
-
在 FieldDescriptor.__new__(cls , name, full_name, index, number, type, cpp_type, ... 559 file=None, create_key=None): # pylint: disable=redefined-builtin --> 560 _message.Message._CheckCalledFromGeneratedFile() 561 if is_extension: 562 return _message.default_pool.FindExtensionByName(full_name) TypeError: Descriptors cannot be created directly
标签: python tensorflow