zoukankan      html  css  js  c++  java
  • ValidationError: Your model ir_version is higher than the checker's

    模型转换为onnx

    import torch
    import torchvision
    dummy_input = torch.randn(10, 3, 224, 224, device="cuda")
    model = torchvision.models.alexnet(pretrained=True).cuda()
    input_names = ["actual_input_1"] + ["learned_%d" % i for i in range(16)]
    output_names = ["output1"]
    
    torch.onnx.export(model, dummy_input, "alexnet.onnx",
                      verbose=True, input_names=input_names, output_names=output_names)
    
    

    转换成功之后会在当前目录生成onnx文件:alexnet.onnx
    模型验证

    import onnx
    model = onnx.load("alexnet.onnx")
    onnx.checker.check_model(model)
    onnx.helper.printable_graph(model.graph)
    

    报错:ValidationError: Your model ir_version is higher than the checker's
    原因:版本不匹配
    原来用的onnx=1.4.1 需要升级一下onnx

    pip install --upgrade onnx
    
    RuntimeError: CUDA error: device-side assert triggered

    报错:

    lambda [](int)->auto::operator()(int)->auto: block: [0,0,0], thread: [32,0,0] Assertion `index >= -sizes[i] && index < sizes[i] && "index out of bounds"` failed.
    

    原因:标签越界,我的配置文件是单类目标检测,使用COCO数据集的时候有80个目标类别,因而导致标签越界。修改配置文件可以解决

  • 相关阅读:
    js浏览器对象
    js对象
    js基础
    css的常见操作
    css 盒子模型
    css定位与浮动
    汇编三(习题)
    pyEcharts安装及使用指南(最新)
    pyEcharts安装及使用指南
    Anaconda安装第三方库与pip和conda 添加国内源
  • 原文地址:https://www.cnblogs.com/luchi88/p/14084529.html
Copyright © 2011-2022 走看看