Closed isgallagher closed 10 months ago
OpenCV does not currently support targets resulting from FindCUDAToolkit.
It looks like Ceras Solver exports these targets regardless of which version of CMake is being used. The only thing I can suggest is trying to build against https://github.com/opencv/opencv/pull/23021 and https://github.com/opencv/opencv_contrib/pull/3400 to see if it solves your issue.
Just out of interest why are you building for Compute 8.7 on WSL are you going to run on a Jetson?
Hi @cudawarped thanks for sharing those PRs. I will try to build against those and see if it works for me. I will be targeting the NVIDIA Jetson AGX Xavier, but I also have a need for local inference for my proof of concept. I started out using OpenCV on Windows, but the image processing is taking too long on the CPU, so I went down the road of building with support for CUDA, and decided to build it on WSL as I thought it would be easier 🤣
I just thought u'll have to build with cmake 3.18+ for OpenCV to use those targets.
but I also have a need for local inference for my proof of concept
Let me know if it works and don't forget to build for your A2000 aswell, I think its Compute 8.6 (-DCUDA_ARCH_BIN=8.6
).
That's right. Looks like the Jetson is SM_72 as well, so I was way off base there.
I am still getting the same errors when using your PRs code.
CMake Error at /home/ian/opencv-pr23021/cmake/OpenCVUtils.cmake:1556 (add_executable):
Target "opencv_test_sfm" links to target "CUDA::cublas" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
Call Stack (most recent call first):
/home/ian/opencv-pr23021/cmake/OpenCVModule.cmake:1304 (ocv_add_executable)
/home/ian/opencv_contrib-pr3400/modules/sfm/CMakeLists.txt:169 (ocv_add_accuracy_tests)
New command line is
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-pr3400/modules -DWITH_CUDA=ON -DOPENCV_DNN_CUDA=ON -DCUDA_ARCH_BIN=8.6 -DCUDAToolkit_LIBRARY_ROOT=/usr/local/cuda-11.7/lib64 -DENABLE_CUDA_FIRST_CLASS_LANGUAGE=ON ..
If I use OpenCV with CMake 3.24 then I don't get any CMake errors regarding CUDA targets however libopencv_sfm
fails to link due to
undefined reference to `google::InitVLOG3__(google::SiteFlag, int, char const*, int)'
I have cmake version 3.16.3 installed on the system. I downloaded cmake-3.24.3 and that worked. Thank you!
I should say I did update the CMakeList.txt for sfm. I'm not sure if it was needed but it didn't give me the error you posted.
At line 109
### CREATE OPENCV SFM MODULE ###
set(extra_dependencies "")
set(optional_dependencies "")
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
list(APPEND extra_dependencies CUDA::cudart_static CUDA::nppial${CUDA_LIB_EXT} CUDA::nppc${CUDA_LIB_EXT} CUDA::nppitc${CUDA_LIB_EXT} CUDA::nppig${CUDA_LIB_EXT} CUDA::nppist${CUDA_LIB_EXT} CUDA::nppidei${CUD> if(HAVE_CUBLAS)
list(APPEND optional_dependencies CUDA::cublas${CUDA_LIB_EXT})
if(NOT CUDA_VERSION VERSION_LESS 10.1)
list(APPEND optional_dependencies CUDA::cublasLt${CUDA_LIB_EXT})
endif()
endif()
if(HAVE_CUFFT)
# static version requires seperable compilation which is incompatible with opencv's current library structure
list(APPEND optional_dependencies CUDA::cufft)
endif()
else()
if(HAVE_CUBLAS)
list(APPEND optional_dependencies ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUFFT)
list(APPEND optional_dependencies ${CUDA_cufft_LIBRARY})
endif()
endif()
ocv_add_module(sfm
opencv_core
opencv_calib3d
opencv_features2d
opencv_xfeatures2d
opencv_imgcodecs
${extra_dependencies}
${optional_dependencies}
WRAP python
)
That's great although I'm not sure that modification is necessary as Ceres should be exporting those targets. I didn't get missing CUDA target errors without it did you?
@isgallagher would it be possible to check if you can build OpenCV without modifying CMakeList.txt for sfm to see if the PR's fix the issue for you.
Either way this looks like an issue with Ceras not OpenCV so should probably be closed. The developers are exporting targets for CMake >= 3.18 when it is built with CMake < 3.18. I am sure there is a reason for this although I am not sure what it is. That is if you are compiling on a machine with CMake 3.16 I don't think you would expect to build a library which can only be imported successfully with CMake >=3.18.
Sorry, I already blew away the build environment as it turns out I don't need OpenCV.
System information (version)
Detailed description
I have Ubuntu 20.04.5 LTS installed on WSL2 on my Windows 10 machine. I followed the OpenCV installation requests, built Ceres Solver, and am attempting to build OpenCV with CUDA support. cmake completes, but it spits out a lot of errors. The first error is below.
Full output:
Steps to reproduce