I want to install OpenCV V4.5.2 from source, so I cloned the repo and the contrib repo from github, checked out to that tag: 4.5.2
and tried to install OpenCV with these flags:
cmake -D CMAKE_BUILD_TYPE=RELEASE \-D CMAKE_INSTALL_PREFIX=/usr/local \-D WITH_CUDA=ON -D WITH_CUBLAS=ON \-D WITH_TBB=ON -D WITH_V4L=ON \-D WITH_QT=OFF -D WITH_OPENGL=ON \-D BUILD_PERF_TESTS=OFF \-D BUILD_opencv_cudacodec=OFF \-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \-D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON\-D OPENCV_ENABLE_NONFREE=ON -D BUILD_NEW_PYTHON_SUPPORT=ON \-D BUILD_opencv_python3=ON -D HAVE_opencv_python3=ON\-D PYTHON_DEFAULT_EXECUTABLE=/usr/bin/python3 \-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda ..
I have CUDA 11.4 installed, I checked that using nvidia-smi
and nvcc -V
, and compiling OpenCV make -j10
works, but when I try to install it after sudo make install
I get this error:
opencv/modules/core/include/opencv2/core/private.cuda.hpp:59:12: fatal error: cuda.h: No such file or directory 59 | # include <cuda.h> | ^~~~~~~~compilation terminated.
CMake finds CUDA on compilation:
-- Could NOT find CUDNN (missing: CUDNN_LIBRARY CUDNN_INCLUDE_DIR) (Required is at least version "7.5")-- CUDA detected: 11.4-- CUDA: Using CUDA_ARCH_BIN=3.5;3.7;5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6-- CUDA NVCC target flags: -gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-D_FORCE_INLINES
and the cuda.h
header file is available in: /usr/local/cuda-11.4/include/cuda.h
and /usr/local/cuda/include/cuda.h
cmake version 3.27.6gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0kernel: 5.15.0-107-genericNVIDIA-SMI 470.239.06 Driver Version: 470.239.06 CUDA Version: 11.4
Can you please tell me how can I solve this issue please? thanks