You are not logged in.
I have been using Tensorflow for years. Last time was 3-4 weeks ago. When I tried to use it today, I am getting a new error:
[juanma@housepc ~]$ python
Python 3.10.10 (main, Mar 5 2023, 22:26:53) [GCC 12.2.1 20230201] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
2023-03-21 12:00:15.211369: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/tensorflow/__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/usr/lib/python3.10/site-packages/tensorflow/python/__init__.py", line 37, in <module>
from tensorflow.python.eager import context
File "/usr/lib/python3.10/site-packages/tensorflow/python/eager/context.py", line 28, in <module>
from tensorflow.core.framework import function_pb2
File "/usr/lib/python3.10/site-packages/tensorflow/core/framework/function_pb2.py", line 5, in <module>
from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/home/juanma/.local/lib/python3.10/site-packages/google/protobuf/internal/__init__.py)
Or using Ipython:
[juanma@housepc ~]$ ipython
Python 3.10.10 (main, Mar 5 2023, 22:26:53) [GCC 12.2.1 20230201]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.11.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import tensorflow as tf
2023-03-21 12:00:00.833308: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import tensorflow as tf
File /usr/lib/python3.10/site-packages/tensorflow/__init__.py:37
34 import sys as _sys
35 import typing as _typing
---> 37 from tensorflow.python.tools import module_util as _module_util
38 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
40 # Make sure code inside the TensorFlow codebase can use tf2.enabled() at import.
File /usr/lib/python3.10/site-packages/tensorflow/python/__init__.py:37
29 # We aim to keep this file minimal and ideally remove completely.
30 # If you are adding a new file with @tf_export decorators,
31 # import it in modules_with_exports.py instead.
32
33 # go/tf-wildcard-import
34 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
---> 37 from tensorflow.python.eager import context
39 # pylint: enable=wildcard-import
40
41 # Bring in subpackages.
42 from tensorflow.python import data
File /usr/lib/python3.10/site-packages/tensorflow/python/eager/context.py:28
25 from absl import logging
26 import numpy as np
---> 28 from tensorflow.core.framework import function_pb2
29 from tensorflow.core.protobuf import config_pb2
30 from tensorflow.core.protobuf import rewriter_config_pb2
File /usr/lib/python3.10/site-packages/tensorflow/core/framework/function_pb2.py:5
1 # -*- coding: utf-8 -*-
2 # Generated by the protocol buffer compiler. DO NOT EDIT!
3 # source: tensorflow/core/framework/function.proto
4 """Generated protocol buffer code."""
----> 5 from google.protobuf.internal import builder as _builder
6 from google.protobuf import descriptor as _descriptor
7 from google.protobuf import descriptor_pool as _descriptor_pool
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/home/juanma/.local/lib/python3.10/site-packages/google/protobuf/internal/__init__.py)
I downgraded TF to the previous package I have, and the error persists. I also made sure I have installed protobuf, protobuf-c and python-protobuf. These packages (the ones related to protobuf) were last updated in December, and I have used TF since then without problems. The only recent update has been tensorflow-opt-cuda to 2.12.0rc1 but as I said, the previous one (2.11.0-2) also gives the same error.
Last edited by joanmanel (2023-03-21 13:33:38)
Offline
You have a local user installation of google.protobuf installed, that appears to be incompatible with the tensorflow version from the official repos.
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
I had protobuf installed through pip. I uninstalled it and all is fine now.
Offline