-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Description
System Information
OpenCV version: 4.10.0, 4.x (branch)
Operating System: Gentoo Linux
CMake: 3.30.0
GPU: GeForce GTX 960M
Native CUDA arch: 50
Detailed description
When configuring OpenCV in the clean build directory, if the ENABLE_CUDA_FIRST_CLASS_LANGUAGE option is set to yes and the MIN_VER_CMAKE is set to 3.18 or higher, CMake ignores values of CUDA_ARCH_BIN and CUDA_ARCH_PTX options.
In this case I only can set NVIDIA GPU arch (OPENCV_CUDA_ARCH_BIN) and NVIDIA PTX archs (OPENCV_CUDA_ARCH_PTX) CMake variables using the CUDAARCHS environment variable.
Steps to reproduce
Note: to reveal the issue on your system, please replace 5.0 with any value different from what OpenCV detects out of the box.
tar -xpf opencv-4.10.0.tar.gz
tar -xpf opencv_contrib-4.10.0.tar.gz
mkdir build
cd build
cmake -DMIN_VER_CMAKE=3.18 -DWITH_CUDA=yes -DCUDA_ARCH_BIN=5.0 -DCUDA_ARCH_PTX=5.0 -DENABLE_CUDA_FIRST_CLASS_LANGUAGE=yes -DOPENCV_EXTRA_MODULES_PATH=.
./opencv_contrib-4.10.0/modules ../opencv-4.10.0 | grep -A2 'NVIDIA CUDA'In my case, it returns this:
warnings from the stderr
CMake Warning (dev) at CMakeLists.txt:127 (enable_language):
project() should be called prior to this enable_language() call.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning at /dev/shm/opencv_contrib-4.10.0/modules/cudacodec/CMakeLists.txt:26 (message):
cudacodec::VideoReader requires Nvidia Video Codec SDK. Please resolve
dependency or disable WITH_NVCUVID=OFF
CMake Warning at /dev/shm/opencv_contrib-4.10.0/modules/cudacodec/CMakeLists.txt:30 (message):
cudacodec::VideoWriter requires Nvidia Video Codec SDK. Please resolve
dependency or disable WITH_NVCUVENC=OFF
-- NVIDIA CUDA: YES (ver 12.5.40, CUFFT CUBLAS)
-- NVIDIA GPU arch: 52
-- NVIDIA PTX archs: 52
The same happens with the latest snapshots of 4.x branches of opencv and opencv_contrib repositories.
In case I remove one or both of MIN_VER_CMAKE and ENABLE_CUDA_FIRST_CLASS_LANGUAGE, it works as expected (with the same warnings).
$ cmake -DWITH_CUDA=yes -DCUDA_ARCH_BIN=5.0 -DCUDA_ARCH_PTX=5.0 -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.10.0/modules ../opencv-4.10.0 2>/dev/null | grep -A2 'NVIDIA CUDA'
-- NVIDIA CUDA: YES (ver 12.5, CUFFT CUBLAS)
-- NVIDIA GPU arch: 50
-- NVIDIA PTX archs: 50The CUDAARCHS environment variable also helps.
$ env CUDAARCHS=50 cmake -DMIN_VER_CMAKE=3.18 -DWITH_CUDA=yes -DCUDA_ARCH_BIN=5.0 -DCUDA_ARCH_PTX=5.0 -DENABLE_CUDA_FIRST_CLASS_LANGUAGE=yes -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.10.0/modules ../opencv-4.10.0 2>/dev/null | grep -A2 'NVIDIA CUDA'
-- NVIDIA CUDA: YES (ver 12.5.40, CUFFT CUBLAS)
-- NVIDIA GPU arch: 50
-- NVIDIA PTX archs: 50Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)