Closed yyyaiyowei0604 closed 2 years ago
add add_definitions(-DAPI_EXPORTS)
below the line add_definitions(-std=c++11)
in your CMakeLists.txt
use this code
`cmake_minimum_required(VERSION 2.6)
project(yolov5)
set(OpenCV_DIR "D:\01Tools\opencv4.5.4\build") #2 set(OpenCV_INCLUDE_DIRS ${OpenCV_DIR}\include) #3 set(OpenCV_LIB_DIRS ${OpenCV_DIR}\x64\vc15\lib) #4 set(OpenCV_Debug_LIBS "opencv_world340d.lib") #5 set(OpenCV_Release_LIBS "opencv_world340.lib") #6 set(TRT_DIR "D:\01Tools\TensorRT-8.2.0.6") #3 set(TRT_INCLUDE_DIRS ${TRT_DIR}\include) #8 set(TRT_LIB_DIRS ${TRT_DIR}\lib) #9 set(Dirent_INCLUDE_DIRS "D:\01Tools\dirent-1.23.2\include") #10
add_definitions(-DAPI_EXPORTS) add_definitions(-std=c++11)
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_BUILD_TYPE Debug)
set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads)
find_package(CUDA REQUIRED) message(STATUS " libraries: ${CUDA_LIBRARIES}") message(STATUS " include path: ${CUDA_INCLUDE_DIRS}")
include_directories(${CUDA_INCLUDE_DIRS})
enable_language(CUDA) # add this line, then no need to setup cuda path in vs
include_directories(${PROJECT_SOURCE_DIR}/include) #11 include_directories(${TRT_INCLUDE_DIRS}) #12 link_directories(${TRT_LIB_DIRS}) #13 include_directories(${OpenCV_INCLUDE_DIRS}) #14 link_directories(${OpenCV_LIB_DIRS}) #15 include_directories(${Dirent_INCLUDE_DIRS}) #16
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -D_MWAITXINTRIN_H_INCLUDED")
find_package(OpenCV QUIET NO_MODULE NO_DEFAULT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_BUILDS_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_SYSTEM_PACKAGE_REGISTRY )
message(STATUS "OpenCV library status:") message(STATUS " version: ${OpenCV_VERSION}") message(STATUS " lib path: ${OpenCV_LIB_DIRS}") message(STATUS " Debug libraries: ${OpenCV_Debug_LIBS}") message(STATUS " Release libraries: ${OpenCV_Release_LIBS}") message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
add_executable(yolov5 ${PROJECT_SOURCE_DIR}/yolov5.cpp ${PROJECT_SOURCE_DIR}/common.hpp ${PROJECT_SOURCE_DIR}/yololayer.cu ${PROJECT_SOURCE_DIR}/yololayer.h) #17
target_link_libraries(yolov5 "nvinfer" "nvinfer_plugin") #18 target_link_libraries(yolov5 debug ${OpenCV_Debug_LIBS}) #19 target_link_libraries(yolov5 optimized ${OpenCV_Release_LIBS}) #20 target_link_libraries(yolov5 ${CUDA_LIBRARIES}) #21 target_link_libraries(yolov5 Threads::Threads)
`
这个问题解决了吗
这个问题解决了吗
解决了,使用下面的CMakeLists.txt
` cmake_minimum_required(VERSION 2.6)
project(yolov5)
set(OpenCV_DIR "D:\01Tools\opencv4.5.4\build") #2 set(TRT_DIR "D:\01Tools\TensorRT-8.2.0.6") #3
add_definitions(-DAPI_EXPORTS) add_definitions(-std=c++11) option(CUDA_USE_STATIC_CUDA_RUNTIME OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_BUILD_TYPE Debug)
set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads)
find_package(CUDA REQUIRED) message(STATUS " libraries: ${CUDA_LIBRARIES}") message(STATUS " include path: ${CUDA_INCLUDE_DIRS}")
include_directories(${CUDA_INCLUDE_DIRS})
enable_language(CUDA) # add this line, then no need to setup cuda path in vs
include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(${TRT_DIR}\include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -D_MWAITXINTRIN_H_INCLUDED")
find_package(OpenCV QUIET NO_MODULE NO_DEFAULT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_BUILDS_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_SYSTEM_PACKAGE_REGISTRY )
message(STATUS "OpenCV library status:") message(STATUS "version: ${OpenCV_VERSION}") message(STATUS "libraries: ${OpenCV_LIBS}") message(STATUS "include path: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS}) link_directories(${TRT_DIR}\lib)
add_executable(yolov5 ${PROJECT_SOURCE_DIR}/yolov5.cpp ${PROJECT_SOURCE_DIR}/yololayer.cu ${PROJECT_SOURCE_DIR}/yololayer.h) #4
target_link_libraries(yolov5 "nvinfer" "nvinfer_plugin") #5 target_link_libraries(yolov5 ${OpenCV_LIBS}) #6 target_link_libraries(yolov5 ${CUDA_LIBRARIES}) #7 target_link_libraries(yolov5 Threads::Threads) #8 `
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
严重性 代码 说明 项目 文件 行 禁止显示状态 错误 MSB3721 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\bin\nvcc.exe" -gencode=arch=COMPUTE_86,code=\"SM_86,COMPUTE_86\" --use-local-env -ccbin "d:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include" -IC:\Users\mingd\tensorrtx\yolov5\include -I"E:\code\TensorRT-8.4.0.6\include" -ID:\Users\opencv\opencv\build\include -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.6\include" --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -std=c++11 -Xcompiler="/EHsc -Zi -Ob0" -g -D_WINDOWS -DAPI_EXPORTS -D"CMAKE_INTDIR=\"Debug\"" -D_MBCS -D_WINDOWS -D_MWAITXINTRIN_H_INCLUDED -DAPI_EXPORTS -D"CMAKE_INTDIR=\"Debug\"" -Xcompiler "/EHsc /W3 /nologo /Od /Fdyolov5.dir\Debug\vc142.pdb /FS /Zi /RTC1 /MDd /GR" -o yolov5.dir\Debug\yololayer.obj "C:\Users\mingd\tensorrtx\yolov5\yololayer.cu"”已退出,返回代码为 1。 yolov5 d:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.6.targets 790
我想请问下我按照上面的cmakelist.txt添加了选项,但是还是报错,请问怎么解决呢。
my procjet has libtorch also. command line will be like this:"diag_suppress**".which make difference. delete "diag_suppress*" works for me.
严重性 代码 说明 项目 文件 行 错误 MSB3721 命令“"D:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64" -x cu -I"D:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include" -IJ:\yolov5\tensorrtx\yolov5\include -I"J:\yolov5\TensorRT-7.2.3.4\include" -I"J:\opencv-4.5.4\build" -I"J:\opencv-4.5.4\include" -I"J:\opencv_contrib-master\modules\cudev\include" -I"J:\opencv-4.5.4\modules\core\include" -I"J:\opencv_contrib-master\modules\cudaarithm\include" -I"J:\opencv-4.5.4\modules\flann\include" -I"J:\opencv-4.5.4\modules\imgproc\include" -I"J:\opencv_contrib-master\modules\intensity_transform\include" -I"J:\opencv-4.5.4\modules\ml\include" -I"J:\opencv_contrib-master\modules\phase_unwrapping\include" -I"J:\opencv_contrib-master\modules\plot\include" -I"J:\opencv_contrib-master\modules\quality\include" -I"J:\opencv_contrib-master\modules\reg\include" -I"J:\opencv_contrib-master\modules\surface_matching\include" -I"J:\opencv_contrib-master\modules\cudafilters\include" -I"J:\opencv_contrib-master\modules\cudaimgproc\include" -I"J:\opencv_contrib-master\modules\cudawarping\include" -I"J:\opencv-4.5.4\modules\dnn\include" -I"J:\opencv_contrib-master\modules\dnn_superres\include" -I"J:\opencv-4.5.4\modules\features2d\include" -I"J:\opencv_contrib-master\modules\fuzzy\include" -I"J:\opencv_contrib-master\modules\hfs\include" -I"J:\opencv-4.5.4\modules\imgcodecs\include" -I"J:\opencv_contrib-master\modules\line_descriptor\include" -I"J:\opencv-4.5.4\modules\photo\include" -I"J:\opencv_contrib-master\modules\saliency\include" -I"J:\opencv_contrib-master\modules\text\include" -I"J:\opencv-4.5.4\modules\videoio\include" -I"J:\opencv_contrib-master\modules\wechat_qrcode\include" -I"J:\opencv_contrib-master\modules\xphoto\include" -I"J:\opencv_contrib-master\modules\barcode\include" -I"J:\opencv-4.5.4\modules\calib3d\include" -I"J:\opencv_contrib-master\modules\cudacodec\include" -I"J:\opencv_contrib-master\modules\cudafeatures2d\include" -I"J:\opencv_contrib-master\modules\cudastereo\include" -I"J:\opencv_contrib-master\modules\datasets\include" -I"J:\opencv-4.5.4\modules\highgui\include" -I"J:\opencv_contrib-master\modules\mcc\include" -I"J:\opencv-4.5.4\modules\objdetect\include" -I"J:\opencv_contrib-master\modules\rapid\include" -I"J:\opencv_contrib-master\modules\rgbd\include" -I"J:\opencv_contrib-master\modules\shape\include" -I"J:\opencv_contrib-master\modules\structured_light\include" -I"J:\opencv-4.5.4\modules\video\include" -I"J:\opencv_contrib-master\modules\xfeatures2d\include" -I"J:\opencv_contrib-master\modules\ximgproc\include" -I"J:\opencv_contrib-master\modules\xobjdetect\include" -I"J:\opencv_contrib-master\modules\aruco\include" -I"J:\opencv_contrib-master\modules\bgsegm\include" -I"J:\opencv_contrib-master\modules\bioinspired\include" -I"J:\opencv_contrib-master\modules\ccalib\include" -I"J:\opencv_contrib-master\modules\cudabgsegm\include" -I"J:\opencv_contrib-master\modules\cudalegacy\include" -I"J:\opencv_contrib-master\modules\cudaobjdetect\include" -I"J:\opencv_contrib-master\modules\dnn_objdetect\include" -I"J:\opencv_contrib-master\modules\dpm\include" -I"J:\opencv_contrib-master\modules\face\include" -I"J:\opencv-4.5.4\modules\gapi\include" -I"J:\opencv_contrib-master\modules\optflow\include" -I"J:\opencv-4.5.4\modules\stitching\include" -I"J:\opencv_contrib-master\modules\tracking\include" -I"J:\opencv_contrib-master\modules\cudaoptflow\include" -I"J:\opencv_contrib-master\modules\stereo\include" -I"J:\opencv_contrib-master\modules\superres\include" -I"J:\opencv_contrib-master\modules\videostab\include" -I"J:\opencv-4.5.4\modules\world\include" -I"J:\opencv_contrib-master\modules\img_hash\include" -I"J:\opencv-4.5.4\modules\ts\include" -I"D:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include" --keep-dir x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -std=c++11 -Xcompiler="/EHsc -Ob2" -D_WINDOWS -DNDEBUG -D"CMAKE_INTDIR=\"Release\"" -DWIN32 -D_WINDOWS -D_MWAITXINTRIN_H_INCLUDED -DNDEBUG -D"CMAKE_INTDIR=\"Release\"" -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Fdyolov5.dir\Release\vc140.pdb /FS /Zi /MD /GR" -o yolov5.dir\Release\yololayer.obj "J:\yolov5\tensorrtx\yolov5\yololayer.cu"”已退出,返回代码为 1。 yolov5 D:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 10.2.targets 764
严重性 代码 说明 项目 文件 行 错误 member "nvinfer1::YoloPluginCreator::mFC" may not be initialized yolov5 J:\yolov5\tensorrtx\yolov5\yololayer.cu 261