wang-xinyu / tensorrtx

Implementation of popular deep learning networks with TensorRT network definition API
MIT License
7k stars 1.77k forks source link

使用yolov5s推理没有检测到目标(空) #1461

Closed B1SH0PP closed 7 months ago

B1SH0PP commented 8 months ago

Env

About this repo

Your problem

使用了yolov5官网的预训练权重yolov5s_v7.0, 并使用该仓库提供的脚本生成.wts文件, 最后生成了.engine, 但是运行后没有目标框, 测试了10多张一个目标都没检测出来. 中途过程中也没有报错啊?

add_definitions(-w) # 关闭警告信息输出 add_definitions(-std=c++11) add_definitions(-DAPI_EXPORTS) set(CMAKE_CXX_STANDARD 11) set(CMAKE_BUILD_TYPE Debug) set(CMAKE_CUDA_ARCHITECTURES 75 86 89) set(THREADS_PREFER_PTHREAD_FLAG ON)

nvcc

set(CMAKE_CUDA_COMPILER "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/bin/nvcc.exe") enable_language(CUDA)

cuda

include_directories("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/include") link_directories("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8/lib/x64")

tensorrt

set(TRT_DIR "C:/Program Files/NVIDIA GPU Computing Toolkit/TensorRT-8.5.3.1/") include_directories(${TRT_DIR}/include) link_directories(${TRT_DIR}/lib)

opencv

set(OpenCV_DIR "C:/SDK/OpenCV/OpenCV_4.6.0/opencv/build/") find_package(OpenCV) include_directories(${OpenCV_INCLUDE_DIRS})

dirent

include_directories("C:/SDK/dirent-1.24")

include_directories("C:/SDK/dirent-1.24/include")

include_directories(${PROJECT_SOURCE_DIR}/src/) include_directories(${PROJECT_SOURCE_DIR}/plugin/) file(GLOB_RECURSE SRCS ${PROJECT_SOURCE_DIR}/src/.cpp ${PROJECT_SOURCE_DIR}/src/.cu) file(GLOB_RECURSE PLUGIN_SRCS ${PROJECT_SOURCE_DIR}/plugin/*.cu) add_library(myplugins SHARED ${PLUGIN_SRCS}) target_link_libraries(myplugins nvinfer cudart)

add_executable(yolov5_det "./yolov5_det.cpp" ${SRCS}) target_link_libraries(yolov5_det nvinfer cudart nvinfer_plugin myplugins ${OpenCV_LIBS})


生成`.engine`:
![image](https://github.com/wang-xinyu/tensorrtx/assets/79520631/64cfbd46-7bfd-4887-91b8-382aba7ef17b)
推理:
![image](https://github.com/wang-xinyu/tensorrtx/assets/79520631/5ce65162-6c4f-47fe-accf-452d6e11aabb)

结果就是为空, 没有目标框, 我就不贴图了, 一个框都没有, 但是中途也没报错呀.
wang-xinyu commented 8 months ago

试下FP32 或者试试TensorRT 8.4

B1SH0PP commented 8 months ago

试下FP32 或者试试TensorRT 8.4

您好! 很高兴真的能收到您的回复! 改为FP32是只要改这里吗? image

我目前改好后, 重新编译, 重新生成了wtsengine文件, 测试下来依然没有效果.

tensorRT 8.4x的版本可能会有点麻烦, 我看我目前装的cuda11.7不支持tensorRT8.4x版本, 这可能会有点耗时, 我待会儿测试下, 我不清楚cuda是否会有版本冲突, 是否得卸载干净.

B1SH0PP commented 8 months ago

@wang-xinyu

wang-xinyu commented 7 months ago

如果是1060,那加下61 arch试试 set(CMAKE_CUDA_ARCHITECTURES 61 75 86 89)

B1SH0PP commented 7 months ago

@wang-xinyu 成功了! 太有实力了哥!

axiaochaochao commented 5 months ago

@wang-xinyu 您好,我也遇到这个问题,我环境是: GPU: GTX3050 OS: WSL2 Ubuntu20.04 Cuda version: 11.6 TensorRT version: TensorRT-8.4.1.5 按照您上面的方法还是没有解决问题,请问这是咋回事么?

wang-xinyu commented 5 months ago

WSL2这种野路子尽量避免,找一个正经ubuntu系统试试

shiyongde commented 2 weeks ago

给力, 一直没找到问题,果然是cuda的arch配置问题!!