Building OpenCV 4.8 with CUDA 11.8 on Ubuntu - unsuccesfull

Yes. Without CUDA and Python I can build.

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_C_COMPILER=/usr/bin/gcc-11 \
-D CMAKE_CXX_COMPILER=/usr/bin/g++-11 \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=OFF \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.x/modules \
-D WITH_QT=OFF ..

This (with CUDA) …

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_C_COMPILER=/usr/bin/gcc-11 \
-D CMAKE_CXX_COMPILER=/usr/bin/g++-11 \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN="8.6;8.9" \
-D WITH_CUDNN=ON \
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.8 \
-D CUDNN_LIBRARY=/usr/local/cuda-11.8/lib64/libcudnn.so.8.6.0 \
-D CUDNN_INCLUDE_DIR=/usr/local/cuda-11.8/include  \
-D OPENCV_DNN_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.x/modules \
-D BUILD_EXAMPLES=OFF \
-D WITH_QT=OFF ..

… also configures the Python, which is interesting. And does not build:

--   Python 3:
--     Interpreter:                 /home/myuser/anaconda3/envs/kb_cv/bin/python3 (ver 3.10.6)
--     Libraries:                   /home/myuser/anaconda3/envs/kb_cv/lib/libpython3.10.so (ver 3.10.6)
--     numpy:                       /home/myuser/.local/lib/python3.10/site-packages/numpy/core/include (ver 1.23.4)
--     install path:                lib/python3.10/site-packages/cv2/python-3.10

Ends with error:

Consolidate compiler generated dependencies of target ittnotify
[  2%] Built target ittnotify
Consolidate compiler generated dependencies of target opencv_core
[  2%] Linking CXX shared library ../../lib/libopencv_core.so
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
[  6%] Built target opencv_core
Consolidate compiler generated dependencies of target opencv_imgproc
[  6%] Linking CXX shared library ../../lib/libopencv_imgproc.so
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: skipping incompatible /usr/local/cuda-11.8/lib64/libcudnn.so when searching for -lcudnn
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/bilateral_filter.dispatch.cpp.o: in function `cv::bilateralFilter(cv::_InputArray const&, cv::_OutputArray const&, int, double, double, int)':
bilateral_filter.dispatch.cpp:(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x1887): undefined reference to `_ZGVbN2v_exp'
/usr/bin/ld: bilateral_filter.dispatch.cpp:(.text._ZN2cv15bilateralFilterERKNS_11_InputArrayERKNS_12_OutputArrayEiddi+0x18a0): undefined reference to `_ZGVbN2v_exp'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/cornersubpix.cpp.o: in function `cv::cornerSubPix(cv::_InputArray const&, cv::_InputOutputArray const&, cv::Size_<int>, cv::Size_<int>, cv::TermCriteria)':
cornersubpix.cpp:(.text._ZN2cv12cornerSubPixERKNS_11_InputArrayERKNS_17_InputOutputArrayENS_5Size_IiEES7_NS_12TermCriteriaE+0x3ba): undefined reference to `_ZGVbN4v_expf'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/gabor.cpp.o: in function `cv::getGaborKernel(cv::Size_<int>, double, double, double, double, double, int)':
gabor.cpp:(.text._ZN2cv14getGaborKernelENS_5Size_IiEEdddddi+0x5a9): undefined reference to `_ZGVbN2v_exp'
/usr/bin/ld: gabor.cpp:(.text._ZN2cv14getGaborKernelENS_5Size_IiEEdddddi+0x5bd): undefined reference to `_ZGVbN2v_exp'
/usr/bin/ld: gabor.cpp:(.text._ZN2cv14getGaborKernelENS_5Size_IiEEdddddi+0x5ff): undefined reference to `_ZGVbN2v_cos'
/usr/bin/ld: gabor.cpp:(.text._ZN2cv14getGaborKernelENS_5Size_IiEEdddddi+0x614): undefined reference to `_ZGVbN2v_cos'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/hough.cpp.o: in function `cv::HoughLinesSDiv(cv::_InputArray const&, cv::_OutputArray const&, int, float, float, int, int, int, int, double, double)':
hough.cpp:(.text._ZN2cvL14HoughLinesSDivERKNS_11_InputArrayERKNS_12_OutputArrayEiffiiiidd+0x32d): undefined reference to `_ZGVbN4v_cosf'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/imgwarp.cpp.o: in function `cv::warpPolar(cv::_InputArray const&, cv::_OutputArray const&, cv::Size_<int>, cv::Point_<float>, double, int)':
imgwarp.cpp:(.text._ZN2cv9warpPolarERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEENS_6Point_IfEEdi+0x24d): undefined reference to `_ZGVbN2v_exp'
/usr/bin/ld: imgwarp.cpp:(.text._ZN2cv9warpPolarERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEENS_6Point_IfEEdi+0x266): undefined reference to `_ZGVbN2v_exp'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/intelligent_scissors.cpp.o: in function `cv::segmentation::IntelligentScissorsMB::IntelligentScissorsMB()':
intelligent_scissors.cpp:(.text._ZN2cv12segmentation21IntelligentScissorsMBC2Ev+0x1f8): undefined reference to `_ZGVbN4v_acosf'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/linefit.cpp.o: in function `cv::weightWelsch(float*, int, float*, float)':
linefit.cpp:(.text._ZN2cvL12weightWelschEPfiS0_f+0xab): undefined reference to `_ZGVbN4v_expf'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/lsd.cpp.o: in function `cv::LineSegmentDetectorImpl::nfa(int const&, int const&, double const&) const':
lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0xd8): undefined reference to `_ZGVbN2v_log'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0xfc): undefined reference to `_ZGVbN2v_log'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x139): undefined reference to `_ZGVbN2vv_pow'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x159): undefined reference to `_ZGVbN2vv_pow'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x349): undefined reference to `_ZGVbN2v_log'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x36e): undefined reference to `_ZGVbN2v_log'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x3b0): undefined reference to `_ZGVbN2vv_pow'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x3d4): undefined reference to `_ZGVbN2vv_pow'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x5e0): undefined reference to `_ZGVbN2v_log'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x608): undefined reference to `_ZGVbN2v_log'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x64d): undefined reference to `_ZGVbN2vv_pow'
/usr/bin/ld: lsd.cpp:(.text._ZNK2cv23LineSegmentDetectorImpl3nfaERKiS2_RKd+0x671): undefined reference to `_ZGVbN2vv_pow'
/usr/bin/ld: CMakeFiles/opencv_imgproc.dir/src/phasecorr.cpp.o: in function `cv::createHanningWindow(cv::_OutputArray const&, cv::Size_<int>, int)':
phasecorr.cpp:(.text._ZN2cv19createHanningWindowERKNS_12_OutputArrayENS_5Size_IiEEi+0x1e7): undefined reference to `_ZGVbN2v_cos'
/usr/bin/ld: phasecorr.cpp:(.text._ZN2cv19createHanningWindowERKNS_12_OutputArrayENS_5Size_IiEEi+0x1fb): undefined reference to `_ZGVbN2v_cos'
collect2: error: ld returned 1 exit status
make[2]: *** [modules/imgproc/CMakeFiles/opencv_imgproc.dir/build.make:1559: lib/libopencv_imgproc.so.4.8.0] Error 1
make[1]: *** [CMakeFiles/Makefile2:4268: modules/imgproc/CMakeFiles/opencv_imgproc.dir/all] Error 2
make: *** [Makefile:166: all] Error 2