Reputation: 41
I've been working on installing and setting up the GPU version of tensorflow for about 8 hours now. I finally got everything full installed, but when I try to test it I get this error:
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
I'll put my installation setup below for reference:
Upvotes: 4
Views: 10753
Reputation: 577
I solved a similar issue (faced while importing tensorflow
module) by downgrading protobuf
from release 4.21.1
to version 3.19.4
$ pip install protobuf
Requirement already satisfied ... (4.21.1)
$ pip uninstall protobuf
Found existing installation: protobuf 4.21.1
Uninstalling protobuf-4.21.1:
Would remove:
/home/kali/.local/lib/python3.10/site-packages/google/protobuf/*
/home/kali/.local/lib/python3.10/site-packages/protobuf-4.21.1-py3.10-nspkg.pth
/home/kali/.local/lib/python3.10/site-packages/protobuf-4.21.1.dist-info/*
Proceed (Y/n)? Y
Successfully uninstalled protobuf-4.21.1
$ pip install protobuf==3.19.4
Upvotes: 4