opencv cann npu 推理崩溃
收藏回复举报
opencv cann npu 推理崩溃
t('forum.solved') 已解决
新人帖
发表于2024-03-22 16:39:58
0 查看

环境:aarch64

1 opencv 4.9版本

2 cann Ascend-cann-toolkit_7.0.0_linux-aarch64.run

3 npu 300ID

4 python 3.8.10

使用opencv+cann+npu推理发现有崩溃问题,报错:

corrupted double-linked list

Aborted (core dumped)

但是可以推理出来正确的结果,仅仅是在结束的时候崩溃的

代码示例:

def main():

    weight_path=opt.weights

    imagepath=opt.imagepath

    print(f"weight:{weight_path}")

    print(f"image:{imagepath}")

    net = cv.dnn.readNet(weight_path)

    net.setPreferableBackend(cv.dnn.DNN_BACKEND_CANN)

    net.setPreferableTarget(cv.dnn.DNN_TARGET_NPU)

    srcimg = cv.imread(imagepath)

    resized_img = cv.resize(srcimg, (640, 640), interpolation=cv.INTER_LINEAR)

    net.setInput(cv.dnn.blobFromImage(resized_img))

    out = net.forward()

    print(out)

if __name__ == "__main__":

    main()

我要发帖子