tensorflow runtime_error ai_generated partial

RuntimeError: XNNPACK delegate not loaded, falling back to default CPU backend

ID: tensorflow/tflite-delegate-not-loaded

Also available as: JSON · Markdown · 中文
82%Fix Rate
86%Confidence
1Evidence
2023-08-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
tensorflow 2.10 active
tensorflow 2.11 active
tensorflow 2.12 active

Root Cause

TFLite interpreter fails to load the XNNPACK delegate, often due to missing or incompatible shared library (libXNNPACK.so) or architecture mismatch (e.g., ARM vs x86).

generic

中文

TFLite 解释器无法加载 XNNPACK 委托,通常是由于缺少或不兼容的共享库(libXNNPACK.so)或架构不匹配(例如 ARM 与 x86)。

Official Documentation

https://www.tensorflow.org/lite/performance/xnnpack

Workarounds

  1. 85% success Install the XNNPACK delegate manually: pip install tflite-runtime and ensure libXNNPACK.so is in LD_LIBRARY_PATH. Alternatively, rebuild TensorFlow Lite with XNNPACK enabled using the build script: bazel build --define xnnpack_support=true //tensorflow/lite/delegates/xnnpack:xnnpack_delegate
    Install the XNNPACK delegate manually: pip install tflite-runtime and ensure libXNNPACK.so is in LD_LIBRARY_PATH. Alternatively, rebuild TensorFlow Lite with XNNPACK enabled using the build script: bazel build --define xnnpack_support=true //tensorflow/lite/delegates/xnnpack:xnnpack_delegate
  2. 95% success Disable XNNPACK delegate and use default CPU backend explicitly: interpreter = tf.lite.Interpreter(model_path, experimental_delegates=[])
    Disable XNNPACK delegate and use default CPU backend explicitly: interpreter = tf.lite.Interpreter(model_path, experimental_delegates=[])

中文步骤

  1. 手动安装 XNNPACK 委托:pip install tflite-runtime 并确保 libXNNPACK.so 在 LD_LIBRARY_PATH 中。或者,使用构建脚本重新编译支持 XNNPACK 的 TensorFlow Lite:bazel build --define xnnpack_support=true //tensorflow/lite/delegates/xnnpack:xnnpack_delegate
  2. 显式禁用 XNNPACK 委托并使用默认 CPU 后端:interpreter = tf.lite.Interpreter(model_path, experimental_delegates=[])

Dead Ends

Common approaches that don't work:

  1. 95% fail

    The environment variable only enables the delegate if the library can be found; it does not install or fix the library.

  2. 70% fail

    Older versions may not have XNNPACK support at all, or may have different delegate APIs.