Error: terminate called after throwing an instance of 'std::runtime_error' terminate called recursively what(): tcm buffer acquire failed for core id 1. terminate called recursively

I want to run models on the NPU, and I’ve converted them all to the int8 16p format, but I get this error when I run them: terminate called after throwing an instance of ‘std::runtime_error’
terminate called recursively
what(): tcm buffer acquire failed for core id 1.
terminate called recursively
I’ve read that upgrading spacemit-ort to 2.0.5 can fix this, but I don’t seem to be able to upgrade to 2.0.5; I can only get 2.0.3.

cml@cml-spacemitk1xmusepiproboard:~$ pip install --upgrade spacemit-ort --break-system-packages
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: Simple Index, https://git.spacemit.com/api/v4/projects/33/packages/pypi/simple
Requirement already satisfied: spacemit-ort in ./.local/lib/python3.12/site-packages (2.0.2+rc3)
Collecting spacemit-ort
Downloading https://git.spacemit.com/api/v4/projects/33/packages/pypi/files/136fc180ec38909cf2975bf2279c72f0d39a7d2fc5740ba86f8cc34c40d3de40/spacemit_ort-2.0.3-py3-none-linux_riscv64.whl (2.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 7.5 MB/s eta 0:00:00
Requirement already satisfied: onnxruntime>=1.24.0 in /usr/lib/python3.12/dist-packages (from spacemit-ort) (1.24.0+spacemit.a3)
Requirement already satisfied: coloredlogs in /usr/lib/python3.12/dist-packages (from onnxruntime>=1.24.0->spacemit-ort) (15.0.1)
Requirement already satisfied: flatbuffers in /usr/lib/python3.12/dist-packages (from onnxruntime>=1.24.0->spacemit-ort) (25.12.19)
Requirement already satisfied: numpy>=2.2.0 in ./.local/lib/python3.12/site-packages (from onnxruntime>=1.24.0->spacemit-ort) (2.5.1)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from onnxruntime>=1.24.0->spacemit-ort) (24.0)
Requirement already satisfied: protobuf in /usr/lib/python3.12/dist-packages (from onnxruntime>=1.24.0->spacemit-ort) (7.35.0)
Requirement already satisfied: sympy in /usr/lib/python3/dist-packages (from onnxruntime>=1.24.0->spacemit-ort) (1.12)
Requirement already satisfied: humanfriendly>=9.1 in /usr/lib/python3.12/dist-packages (from coloredlogs->onnxruntime>=1.24.0->spacemit-ort) (10.0)
Installing collected packages: spacemit-ort
Attempting uninstall: spacemit-ort
Found existing installation: spacemit-ort 2.0.2+rc3
Uninstalling spacemit-ort-2.0.2+rc3:
Successfully uninstalled spacemit-ort-2.0.2+rc3
Successfully installed spacemit-ort-2.0.3

如果spacemit.pypi暂时没有更新,那么最新的whl包,可以从Release v2.0.5 · spacemit-com/onnxruntime · GitHub 下载解压获得

好的,我尝试一下

补充一个不需要 GitHub 的升级路径,我刚在 K1(Bianbu 2.3)上完整验证过:

1. EP 2.0.5 直接从 Spacemit 私有 PyPI 下载(国内直连):

pip3 download spacemit-ort==2.0.5 --no-deps \
  --index-url https://git.spacemit.com/api/v4/projects/33/packages/pypi/simple
# 解压 whl(whl 就是 zip),得到 spacemit_ort/ 目录,内含 libspacemit_ep.so.2.0.5

2. 加载方式有个坑(重要): 不要把它 pip 装进 venv 和 pip 版 onnxruntime
搭配——会报 undefined symbol: _ZTIN11onnxruntime18IExecutionProviderE。
正确姿势是保留系统 apt 的 onnxruntime,用 PYTHONPATH 指到解压目录覆盖:

PYTHONPATH=/path/to/解压目录 python3 your_script.py

3. import 顺序(和论坛流传的说法相反):

import onnxruntime as ort   # 先
import spacemit_ort         # 后

先 import EP 的话它会加载失败(符号还没进内存)——我实测 2.0.5 必须
onnxruntime 在前。

4. 升级完先跑个最小验证(用 ort 自带小模型确认 EP 通路):

import onnxruntime as ort
import spacemit_ort
import numpy as np
print(ort.get_available_providers())
model = "/usr/lib/python3.12/dist-packages/onnxruntime/datasets/logreg_iris.onnx"
x = np.random.rand(3, 2).astype(np.float32)
sess = ort.InferenceSession(model, providers=["SpaceMITExecutionProvider"])
print(sess.run(None, {"float_input": x}))

5. 如果升级后你的 int8 模型还有问题——检查一下模型是用什么量化的。
EP 对量化格式有要求(对称量化等),onnxruntime.quantization / ultralytics
直接导出的可能不被支持,要用 xslim(也在上面那个私有 PyPI,x86 上跑)。
我实测官方 ModelZoo 的量化 yolo(detection.tar.gz)配 EP 2.0.5 能到
13× 加速(175ms vs CPU 2277ms)——值得把格式调对。