专栏算法工具链from horizon_nn.torch import export_onnx报错

from horizon_nn.torch import export_onnx报错

已解决
z2025-07-18
48
6
from horizon_nn.torch import export_onnx报错ModuleNotFoundError: No module named 'horizon_nn.torch',是在cpu的docker里跑的
pip list 显示有horizon_nn,安装的是cpu版本的docker,python3环境里import horizon不报错

 

算法工具链
技术深度解析
评论2
0/1000
  • Huanghui
    Lv.5

    你好, from horizon_nn.converter.parser.torch_parser import export_onnx,用这个吧

    2025-07-18
    0
    4
    • z回复Huanghui:

      好的

      2025-07-18
      0
    • z回复z:

      你好,用 export_onnx导出了 gridsample算子 ,但是我用onnx推理时出错了,是要用地平线的推理吗

      Traceback (most recent call last): File "D:\my_project\XFeat-ONNX\onnx_match_images_e2e.py", line 57, in main() File "D:\my_project\XFeat-ONNX\onnx_match_images_e2e.py", line 27, in main session = onnxruntime.InferenceSession(fname_model) File "D:\miniforge3\envs\xfeat\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 419, in __init__ self._create_inference_session(providers, provider_options, disabled_optimizers) File "D:\miniforge3\envs\xfeat\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 480, in _create_inference_session sess = C.InferenceSession(session_options, self._model_path, True, self._read_config_from_model) onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from weights/xfeat_e2e_600x800.onnx failed:Fatal error: horizon:GridSample(-1) is not a registered function/op

      2025-07-18
      0
    • Huanghui回复z:

      是的,onnxruntime不行的,这里要用hb_runtime推理

      2025-07-18
      0
    • z回复Huanghui:

      好的

      2025-07-18
      0
  • Huanghui
    Lv.5

    因为版本迭代,之前那个不能用了,用现在这个

    2025-07-18
    0
    0