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个目标类别,因而导致标签越界。修改配置文件可以解决

posted @ 2020-12-04 10:44  早上好章鱼哥  阅读(3009)  评论(0编辑  收藏  举报