-
Notifications
You must be signed in to change notification settings - Fork 75k
Closed
Labels
comp:liteTF Lite related issuesTF Lite related issuestype:bugBugBugtype:build/installBuild and install issuesBuild and install issues
Description
When compiling the TensorFlow Lite Python wheel for Raspberry Pi (as described on https://www.tensorflow.org/lite/guide/build_cmake_pip), the result throws an exception when I try to use it:
Traceback (most recent call last):
File ".../venv/lib/python3.7/site-packages/tflite_runtime/interpreter.py", line 45, in <module>
from tensorflow.lite.python import metrics_portable as metrics
ModuleNotFoundError: No module named 'tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
import tflite_runtime.interpreter as tflite
File ".../venv/lib/python3.7/site-packages/tflite_runtime/interpreter.py", line 47, in <module>
from tensorflow.lite.python import metrics_nonportable as metrics
ModuleNotFoundError: No module named 'tensorflow'
The offending lines were added in change a1825c9, in the file tensorflow/lite/python/interpreter.py:
diff --git a/tensorflow/lite/python/interpreter.py b/tensorflow/lite/python/interpreter.py
index f7ef3b34ba6..5c5898b6d4d 100644
--- a/tensorflow/lite/python/interpreter.py
+++ b/tensorflow/lite/python/interpreter.py
@@ -40,6 +40,13 @@ else:
return lambda x: x
+try:
+ from tensorflow.lite.python import metrics_portable as metrics
+except ImportError:
+ from tensorflow.lite.python import metrics_nonportable as metrics
+# pylint: enable=g-import-not-at-top
+
+
class Delegate(object):
"""Python wrapper class to manage TfLiteDelegate objects.
@@ -321,6 +328,9 @@ class Interpreter(object):
delegate._get_native_delegate_pointer()) # pylint: disable=protected-access
self._signature_defs = self.get_signature_list()
+ self._metrics = metrics.TFLiteMetrics()
+ self._metrics.increase_counter_interpreter_creation()
+
def __del__(self):
# Must make sure the interpreter is destroyed before things that
# are used by it like the delegates. NOTE this only works on CPython
I removed these lines from the copy of interpreter.py after installing the wheel and the rest of the code works fine.
It appears that these metrics are needed for unit testing, but something needs to be changed so they are not used when the TFLite package is run a system where TensorFlow itself is not present (e.g. a small platform like Raspberry Pi).
Metadata
Metadata
Assignees
Labels
comp:liteTF Lite related issuesTF Lite related issuestype:bugBugBugtype:build/installBuild and install issuesBuild and install issues