tensorflow runtime_error ai_generated partial

RuntimeError: XNNPACK 委托未加载,回退到默认 CPU 后端

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

ID: tensorflow/tflite-delegate-not-loaded

其他格式: JSON · Markdown 中文 · English
82%修复率
86%置信度
1证据数
2023-08-20首次发现

版本兼容性

版本状态引入弃用备注
tensorflow 2.10 active
tensorflow 2.11 active
tensorflow 2.12 active

根因分析

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

English

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

官方文档

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

解决方案

  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=[])

无效尝试

常见但无效的做法:

  1. 95% 失败

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

  2. 70% 失败

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