在K3尝试一个跟踪的:python的onnx推mixformerv2在服务器已经能做正常推,但是按照你们的文档去加spacemit_onnx,能加载模型,但是run的时候会抛一个reshape的维度问题,没找到resahpe的限制说明
使用onnxruntime+SpaceMITExecutionProvider推理产生的bug,烦请以下面的方式说明,
硬件及操作系统:例如K1@bianbu 2.2 (lsb_release -a可查询)
SpacemiTORT版本:例如2.0.2+rc1,Python or C&C++
模型名称:如果它是个公版模型提供一个名字,如果是自己的模型,提供一个相似的能够复现的公版模型名字
模型文件:如果能够提供可复现模型,请将模型等可复现文件发给社区相关负责人(或邮箱jinghui.huang@spacemit.com),主题【SpacemiT-ORT-BUG】,如方便,最好提供量化配置Json文件及demo脚本
更详细的说明:量化方式(静态量化or动态量化)、该模型是否在其他推理方式下能够正常运行等
硬件及操作系统:K3@Bianbu 4.0beta1;
SpacemiTORT版本:k3默认的,都是apt直接安装的;
模型名称:mixformer_v2.onnx;
模型文件:源代码,模型,测试视频已经邮件。
更详细的说明:未做量化,直接用的onnx测试的,看文档不量化也能跑。
onnxruntime:1.24.0+spacemit.a3;
spacemit-ort:2.0.2+beta1
pip install spacemit-ort==2.0.2+rc3 板子上的spacemit-ort先升级一下,然后这个模型你用xslim精简一下,在x86上pip install xslim,python3 -m xslim -i mixformer_v2.onnx -o mixformer_v2.sim.onnx,然后就跑这个mixformer_v2.sim.onnx,详细的xslim使用参考 spacemit-com/xslim @1776324254
好的,我们先按照你的做量化,试一下
xslim包含fp32-fp32的模型精简,fp32-fp16,动态量化,静态量化,所有的模型都可以过一下xslim,不管量化还是不量化
升级spacemit-ort:
bianbu@k3:~/Desktop/20260417/mixformer$ pip install spacemit-ort==2.0.2+rc3
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.13/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
用虚拟环境:
(spacemit-env) bianbu@k3:~$ pip install spacemit-ort==2.0.2+rc3
ERROR: Could not find a version that satisfies the requirement spacemit-ort==2.0.2+rc3 (from versions: none)
ERROR: No matching distribution found for spacemit-ort==2.0.2+rc3
系统的python,
pip install spacemit-ort==2.0.2+rc3 --break-system-packages
执行即可,虚拟环境的话,补上pypi源,
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set global.extra-index-url https://git.spacemit.com/api/v4/projects/33/packages/pypi/simple
我们使用的是贵司在线上给我们开通的账号。
按照你的方法升级了spacemit-ort,版本如下:
bianbu@k3:~/Desktop/20260417/mixformer$ pip list | grep spacemit
onnxruntime 1.24.0+spacemit.a3
spacemit-ort 2.0.2+rc3
运行mixformerv2报错如下:
bianbu@k3:~/Desktop/20260417/mixformer$ python3 infer_mixformer_v2.py --model mixformer_v2_xsim.onnx --device spacemit --bbox 316 136 112 120 --video bag.avi
terminate called after throwing an instance of ‘std::runtime_error’
what(): tcm buffer alloc failed for core id 11.
已中止 (核心已转储) python3 infer_mixformer_v2.py --model mixformer_v2_xsim.onnx --device spacemit --bbox 316 136 112 120 --video bag.avi
云平台的os版本可能没更新,没有预装spacemit-tcm驱动,可以试一下 apt update 及 apt install spacemit-tcm,如果找不到这个包的话,lsb_release -a看下bianbu os的版本,如果已经有这个包还报错的话,看看云平台的k3能不能reboot,重启之后tcm状态会清除
apt update后无法安装spacemit-tcm,使用sudo apt search spacemit-tcm找不到spacemit-tcm。lsb_release -a信息如下:
bianbu@k3:~/Desktop/20260417/mixformer$ lsb_release -a
No LSB modules are available.
Distributor ID: Bianbu
Description: Bianbu 4.0beta1
Release: 4.0beta1
Codename: resolute
。K3 reboot之后运行程序,和之前一样的错误:
bianbu@k3:~/Desktop/20260417/mixformer$ python3 infer_mixformer_v2.py --model mixformer_v2_xsim.onnx --device spacemit --bbox 316 136 112 120 --video bag.avi
terminate called after throwing an instance of ‘std::runtime_error’
terminate called recursively
已中止 (核心已转储) python3 infer_mixformer_v2.py --model mixformer_v2_xsim.onnx --device spacemit --bbox 316 136 112 120 --video bag.avi
自己这边之前给你邮箱jinghui.huang@spacemit.com发送过源代码、模型、测试视频,要不你在K3板子上试一试。
邮件主题为: SpacemiT-ORT-BUG。
发送者邮箱:zhouyuhua_ict@163.com。
bianbu@k3:~/Desktop/20260417/mixformer$ whereis spacemit-tcm
spacemit-tcm:
bianbu@k3:~/Desktop/20260417/mixformer$ sudo apt install spacemit-tcm
[sudo: authenticate] Password:
错误: 无法定位软件包 spacemit-tcm
bianbu@k3:~/Desktop/20260417/mixformer$ apt search spacemit
bianbu-esos/resolute-porting 1.0.0~beta1+20260305010248 riscv64 [可从该版本升级:1.0.0~beta1]
ESOS(Energy Service OS) for SpacemiT platforms
k1-udev-rules/resolute-customization,now 2.0.2+beta1+fix riscv64 [已安装,自动]
SpacemiT udev rules for K1
linux-firmware-spacemit/resolute-porting,now 0.0.6 riscv64 [已安装,自动]
auto-generated package by debmake
llama.cpp-tools-spacemit/resolute-porting 0.0.1-6 riscv64
Prebuilt llama.cpp tools and libraries (Spacemit)
onnxruntime/resolute-customization,now 2.0.2+beta1+fix riscv64 [已安装]
An AI runtime engine based on onnxruntime
opencv-spacemit/resolute-porting 4.14.0-1bianbu2 riscv64
OpenCV optimized for Spacemit platform
opencv-spacemit-dbgsym/resolute-porting 4.14.0-1bianbu2 riscv64
debug symbols for opencv-spacemit
opensbi-spacemit/resolute-porting 1.0.0~beta1+20260305010237 all [可从该版本升级:1.0.0~beta1]
RISC-V Open Source Supervisor Binary Interface
python3-spacemit-ort/resolute-customization,now 2.0.2+beta1+fix riscv64 [已安装,自动]
Python3 package for AI engine based on onnxruntime
python3-spacemit-ort-dbgsym/resolute-customization 2.0.2+beta1 riscv64
debug symbols for python3-spacemit-ort
spacemit-code-forge/resolute-customization,now 0.0.6 riscv64 [已安装,自动]
auto-generated package by debmake
spacemit-flash-dtbs/resolute-porting,now 1.3.5 riscv64 [已安装,自动]
spacemit-flash-dtbs is a script which will put the dtbs in the boot location of devices.
spacemit-ollama-toolkit/resolute-porting 0.0.13 riscv64
ollama toolkit
u-boot-spacemit/resolute-porting 1.0.0~beta1+20260305010243 all [可从该版本升级:1.0.0~beta1]
A boot loader for SpacemiT systems
zenow-spacemit/resolute-porting 0.0.16 riscv64
zenow-spacemit - Local LLM Chat Application
你这边是用的–device spacemit,而不是cpu跑的吗?看起来60Tops的算力有点慢。这个60Tops是INT8,是吗?
帮我量化成INT8精度看看速度~
14.4T dense int8,60T sparse int4,7.2T fp16





