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
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).
官方文档
https://www.tensorflow.org/lite/performance/xnnpack解决方案
-
手动安装 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
-
显式禁用 XNNPACK 委托并使用默认 CPU 后端:interpreter = tf.lite.Interpreter(model_path, experimental_delegates=[])
无效尝试
常见但无效的做法:
-
95% 失败
The environment variable only enables the delegate if the library can be found; it does not install or fix the library.
-
70% 失败
Older versions may not have XNNPACK support at all, or may have different delegate APIs.