fatal error: NvInfer.h: No such file or directory | 报错处理
💜 遇到报错【 fatal error: NvInfer.h: No such file or directory】:
fatal error: NvInfer.h: No such file or directory
#include "NvInfer.h"
通过 find -name NvInfer.h 查找发现 该头文件所在目录
可以发现,该头文件 是属于 TensorRT 下的一个 专有头文件,因此我们的C++ 代码在编译时需要能够找到它
find -name NvInfer.h
./project/project21/modelTrans/tensorRT/tensorRT7/TensorRT-7.0.0.11/include/NvInfer.h
./project/project21/modelTrans/tensorRT/tensorRT7/TensorRT-7.1.3.4/include/NvInfer.h
./project/project21/modelTrans/tensorRT/tensorRt8/TensorRT-8.0.0.3/include/NvInfer.h
./project/project21/modelTrans/transPro/yolo-tensorrt/modules/NvInfer.h
❤️ 解决方法
在 CMakeLists.txt 中 配置 TensorRT-8
# tensorRT
include_directories(/home/墨理/project/project21/modelTrans/tensorRT/tensorRt8/TensorRT-8.0.0.3/include/)
link_directories(/home/墨理/project/project21/modelTrans/tensorRT/tensorRt8/TensorRT-8.0.0.3/lib/)
💜 遇到报错 【NvInferRuntimeCommon.h:1203:18: error: overriding ‘virtual void nvinfer1::ILogger::log】:
crnn/logging.h 下的 log() 方法 和 NvInferRuntimeCommon.h 中的 log() 方法 重复定义
/home/墨理/project/project21Next/modelTrans/tvm/tensorrtx_Cuda11/crnn/logging.h:239:10: error: looser throw specifier for ‘virtual void Logger::log(nvinfer1::ILogger::Severity, const char*)’
void log(Severity severity, const char* msg) override
...
TensorRT-8.0.0.3/include/NvInferRuntimeCommon.h:1203:18: error: overriding ‘virtual void nvinfer1::ILogger::log(nvinfer1::ILogger::Severity, const AsciiChar*) noexcept’
virtual void log(Severity severity, AsciiChar const* msg) noexcept = 0;
观察 crnn/logging.h 发现
void log(Severity severity, const char* msg) override
{
LogStreamConsumer(mReportableSeverity, severity) << "[TRT] " << std::string(msg) << std::endl;
}
❤️ 解决方法,使用 cuda-10 + tensorRT7 的组合,该冲突即消失
# cuda
include_directories(/usr/local/cuda-10.0/include)
link_directories(/usr/local/cuda-10.0/lib64)
# tensorRT
#include_directories(/home/墨理/project/project21/modelTrans/tensorRT/tensorRt8/TensorRT-8.0.0.3/include/)
#link_directories(/home/墨理/project/project21/modelTrans/tensorRT/tensorRt8/TensorRT-8.0.0.3/lib/)
# tensorRT 7
include_directories(/home/墨理/project/project21/modelTrans/tensorRT/tensorRT7/TensorRT-7.0.0.11/include/)
link_directories(/home/墨理/project/project21/modelTrans/tensorRT/tensorRT7/TensorRT-7.0.0.11/lib/)
💬 其它遇到的报错
🚀🚀 文末专栏推荐部分 🚀🚀
- 🍖 如果感觉文章看完了不过瘾,还想更进一步,那么可以来【墨理】其他 专栏 看一下哦~
- ❤️ 图像风格转换 —— 代码环境搭建 实战教程【关注即可阅】!
- 💜 图像修复-代码环境搭建-知识总结 实战教程 【据说还行】
- 💙 超分重建-代码环境搭建-知识总结 解秘如何让白月光更清晰【脱单神器】
- 💛 YOLO专栏,只有实战,不讲道理 目标检测【建议收藏】!
- ❤️ 趣学深度学习 —— 了解有趣AI 深度学习入门项目【很有意思】!
- 🍖 个人整理的Cuda系列 Linux安装教程【适合小白进阶】
- 💜 ubuntu18给当前用户安装cuda11.2 图文教程 | 配置cuDNN8.1 |
- 💜 Linux服务器下给当前用户安装自己的CUDA10.0
- 💜 Linux下cuda10.0安装Pytorch和Torchvision
- 💜 Linux 可以安装多个版本的Cuda 吗 | 给我一台新的服务器,我会怎么安排 Cuda
- 💜 查看CUDA和cuDNN的版本号
- 🍖 深度学习、调参搬砖、开发利器【大佬必备】
- ❤️ VSCode远程连接 Linux 服务器进行开发调试 | C++远程调试 | Python远程调试 | VSCode 神器 ,你值得拥有
- ❤️ windows下 pycharm配置Linux服务器的 conda环境之最强指南 | 深度学习模型远程调试 | SFTP 同步传输 |