4

I am trying to build openCV 4.0.0 with cuda 11 on Ubuntu 18.04. following is my cmakefile

cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_C_COMPILER=/usr/bin/gcc-7 \
  -D CMAKE_INSTALL_PREFIX=/usr/local/OpenCV-4.0.0 \
  -D INSTALL_PYTHON_EXAMPLES=ON \
  -D INSTALL_C_EXAMPLES=OFF \
  -D WITH_TBB=ON \
  -D WITH_CUDA=ON \
  -D WITH_CUDNN=ON \
  -D OPENCV_DNN_CUDA=ON \
  -D CUDA_ARCH_BIN=7.5 \
  -D BUILD_opencv_cudacodec=OFF \
  -D ENABLE_FAST_MATH=1 \
  -D CUDA_FAST_MATH=1 \
  -D WITH_CUBLAS=1 \
  -D WITH_V4L=ON \
  -D WITH_QT=OFF \
  -D WITH_OPENGL=ON \
  -D WITH_GSTREAMER=ON \
  -D OPENCV_GENERATE_PKGCONFIG=ON \
  -D OPENCV_PC_FILE_NAME=opencv.pc \
  -D OPENCV_ENABLE_NONFREE=ON \
  -D OPENCV_PYTHON3_INSTALL_PATH=~/.virtualenvs/cv/lib/python3.6/site-packages \
  -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-4.0.0/modules \
  -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
  -D BUILD_EXAMPLES=ON ..

I am getting the following error

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppicom_LIBRARY (ADVANCED)
    linked by target "opencv_cudev" in directory /home/ali/opencv_contrib-4.0.0/modules/cudev
    linked by target "opencv_cudev" in directory /home/ali/opencv_contrib-4.0.0/modules/cudev
    linked by target "opencv_test_cudev" in directory /home/ali/opencv_contrib-4.0.0/modules/cudev/test
    linked by target "opencv_test_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_perf_core" in directory /home/ali/opencv-4.0.0/modules/core
    linked by target "opencv_test_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_perf_cudaarithm" in directory /home/ali/opencv_contrib-4.0.0/modules/cudaarithm
    linked by target "opencv_flann" in directory /home/ali/opencv-4.0.0/modules/flann
    linked by target "opencv_flann" in directory /home/ali/opencv-4.0.0/modules/flann
    linked by target "opencv_test_flann" in directory /home/ali/opencv-4.0.0/modules/flann
    linked by target "opencv_test_hdf" in directory /home/ali/opencv_contrib-4.0.0/modules/hdf
    linked by target "opencv_hdf" in directory /home/ali/opencv_contrib-4.0.0/modules/hdf
    linked by target "opencv_hdf" in directory /home/ali/opencv_contrib-4.0.0/modules/hdf
    linked by target "opencv_test_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc
    linked by target "opencv_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc
    linked by target "opencv_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc
    linked by target "opencv_perf_imgproc" in directory /home/ali/opencv-4.0.0/modules/imgproc

I tested the cuda/cudnn examples and they run fine. Any help would be much appreciated.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Ali
  • 141
  • 3
  • 12
  • 3
    It is quite possible that neither CMake nor the makefile you are using, not opencv actually have CUDA 11 support. It was only release 4 days ago – talonmies Jun 10 '20 at 07:33
  • 2
    According to the [NPP documentation](https://docs.nvidia.com/cuda/npp/index.html): **Note that NPP has deprecated the nppicom JPEG compression library as of NPP 11.0, use the NVJPEG library instead.** So OpenCV must update its CMakeLists to support this change. – Johny Jun 11 '20 at 11:40
  • @talonmies Now I installed cuda-11.0. When I make opencv, make part detected my CUDA-11.0 too. but I still get similar errors to this guy. Are these errors just cos of opencv4.x.x not compatible with CUDA-11.0 or can there be another reason too? – Yunus Temurlenk Jun 19 '20 at 11:41
  • @Ali Could you find any solution to your problem ? – Yunus Temurlenk Jun 19 '20 at 12:10
  • @Johny Could you please elaborate. Do i have to uninstall the NPP and install NVJPEG. if yes then how. and how would i make changes in the Cmakelists of opencv. – Ali Jun 22 '20 at 03:26
  • @talonmies I don't think that's the case. I might be something that Johny is suggesting but i am not able to get any solution. – Ali Jun 22 '20 at 05:10

6 Answers6

3

It seems to be because of version compatibility issues. I had been looking for a solution to the same issue for two weeks. I was trying to get OpenCV-4.2.0 to work on Ubuntu-20.04 with CUDA-11.1 and CUDNN-8.0.5, but it never worked.

After reading @antb52's comment, I tried to install OpenCV-4.4.0 instead, and it worked! Now, problem solved!!!

zero2smthg
  • 31
  • 2
1

In my case for CUDA 11.1 with OpenCV 4.4.0 on Ubuntu 18.04, Adding -DCUDA_nppicom_LIBRARY=true to cmake in Dockerfile solved the issue.

1

I would recommend just to checkout from the master branch the FindCUDA.cmake and OpenCVDetectCuda.cmake

(For this fix you need to have it cloned from github)

If not:

git clone https://github.com/opencv/opencv.git

cd opencv; git checkout 4.2.0

Now you are ready to get from master the files:

git checkout master cmake/FindCUDA.cmake cmake/OpenCVDetectCUDA.cmake

rm -r build/; mkdir build; cd build; #Erase cache

Now you are ready to build!

cmake [ OPTIONS ] ..

As I have read before, CUDA has changed a lot. At versions greater than 7.5, the nppi library seemed to be split in multiple libraries, and above 11 (I guess) nppicom was deleted. Greater OpenCV versions handle this, but 4.2 doesn't.

careway
  • 21
  • 3
0

try run cmake-gui .. or ccmake .. in build folder to see all options, the error show that cmake cannot detect the location of the dependencies...

cmake-gui comes with the newest cmake, download it from here.

don't forget to uninstall the old ones if you want to install the newest cmake

ccmake is similar, just different gui..., to install sudo apt install cmake-curses-gui. when installing ccmake, you don't need uninstall the cmake, you can use the old ones.

when you run it, you will see many configuration, set the folder of dependencies that said NOT FOUND (that causes error), to the folder where the dependencies installed.

if you not yet install the dependencies, install it, pointing the folder and re-configure again..

if one or more problem occurs in installing, then you decide to not use it, looking for the option WITH_the_dependencies, and set it OFF to prevent the error.

Wahyu Bram
  • 413
  • 1
  • 7
  • 13
  • i want to build it with cuda support where i am getting the errors. and i tried with both command line and gui. both have the same errors. – Ali Jun 22 '20 at 03:30
  • you must understood opencv is like a framework, like put all metodh in one packages. mean while each method to be works, need dependencies, cuda is only a 'connector' to make you can do all calculation in GPU. so.., base my experience in several times install opencv that binding to cuda, the error is raised because of that the dependencies to use a module in CV, not exists.. mean while, my configuration is set the opencv to push add it. so the options in facing that situation is: install the dependencies or sacrifice the module. – Wahyu Bram Aug 30 '20 at 04:16
  • try to read this, may be your problem is similar. https://stackoverflow.com/questions/46584000/cmake-error-variables-are-set-to-notfound @johny has answer the problem is because the dependencies that needed is deprecated. so maybe you could fix the problem if you follow the step that recommended by api55 in the link above. – Wahyu Bram Aug 30 '20 at 04:25
0

I have the same problem, looks like nppicom is deprecated so you will need to ignore it in the FindCUDA.cmake file, as shown in this link

anhtu.do1998
  • 111
  • 1
  • 3
0

not so direct, CUDA 11.0 need c++14 and an an up to date compiler g++-9 but opencv stay in c++11, lot of problems, better wait for opencv 4.4. The same stuff for libcudnn8 who break the api and the include (cudnn_version_v8.h for example). good luck

antb52
  • 31
  • 2
  • 6