一、问题描述
使用github开源模型转换工具tensorrtx,编译人脸检测算法retinaface,将.wts类型权重生成.engine类型权重时,报以下错误:

/tensorrtx/retinaface/decode.h:6:10: fatal error: NvInfer.h: No such file or directory
 #include "NvInfer.h"

二、解决方法
问题出现原因是,NvInfer.h 中声明和定义了 tensorRT 中的大部分变量、函数、类等内容,报这个错误是没有安装tensorrt(乖乖安装)或者安装了没有链接进自己工程(cmake方式可以通过下面方法链接)。
通过cmake将tensorRT对应的头文件和库链接进项目里。
cmakelist.txt里添加:

include_directories(/home/******/TensorRT-7.2.3.4/include)
link_directories(/home/******/TensorRT-7.2.3.4/lib/)

注:编译其他算法,比如yolov5啥的,遇到这个错误,也可以这么试试,应该是同一个问题。

Logo

GitCode AI社区是一款由 GitCode 团队打造的智能助手,AI大模型社区、提供国内外头部大模型及数据集服务。

更多推荐