Can not find CUDA_NPP_LIBRARY_ROOT_DIR in cmake - opencv

I am trying to install opencv 2.2 with cuda enabled. I have installed CUDA and also have compiled and tested some programs with it.
Now I want to install opencv with gpu. I downloaded cmake-gui and set CUDA on. When I hit the configure button it does find cuda toolkit but gives me this error:
CMake Error at modules/gpu/FindNPP.cmake:102 (message):
NPP headers/libraries are not found. Please specify
CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.
Call Stack (most recent call first):
modules/gpu/CMakeLists.txt:38 (find_package)
I have installed everything in the default directory.
My cuda-toolkit version is 4.0. Also I have opencv 2.2 without gpu installed.
And in case it might help:
My OS is ubuntu 11.04, my gpu is geforce gtx550, and my cuda driver version is 280.13

Related

EasyOCR disables Cuda GPU when installed

Hello after installing EasyOCR via pip install easyocr via Anaconda Prompt (base) I receive this error.
OpenCV(4.5.4)
D:\a\opencv-python\opencv-python\opencv\modules\core\include\opencv2/core/private.cuda.hpp:106: error: (-216:No CUDA support) The library is compiled without CUDA
support in function 'throw_no_cuda'
Before installing easyocr, cuda is active and working with my GPU, but is disabled after installing EasyOCR.
I complied my build via Cmake using opencv4.5.4 and opencv-contrib4.5.4 with Cuda 11.3.1 and Cudnn 8.4.0 as well as uprading tot he most recent numpy 1.22.3.
It seems that after installing eascyOCR is changes my opencv build from whatever I am using to "opencv-python-headless-4.5.4.60" and that is I believe where the issues is at.
This is the version of easyocr installed.
Downloading opencv_python_headless-4.5.4.60-cp39-cp39-win_amd64.whl (35.0 MB)
Successfully installed easyocr-1.4.2 opencv-python-headless-4.5.4.60 python-bidi-0.4.2
Any idea or help on how I can get easyocr working with Cuda and my GPU?
Solved,
Have to install EasyOCR first
Then build OPENCV

Using GPU in OpenCV

If I want to use my computer's GPU with OpenCV, is it necessary that I build OpenCV from source with CUDA enabled? Or can I install OpenCV with CUDA support via apt-get? I noticed the following 2 packages in apt-get:
libopencv-gpu-dev - development files for libopencv-gpu2.4v5
libopencv-gpu2.4v5 - computer vision GPU library
But I am not sure if these will work with OpenCV3 or if they are only compatible with OpenCV2. I know that the gpu module in Opencv2 was split up into multiple CUDA modules in OpenCV3.
Yes it is necessary that you build opencv from the source with CUDA option enabled. The apt-get packages won't work with OpenCV3 and above versions. I suggest you install the CUDA Toolkit first and then attempt installation of OpenCV or the GPU functions won't work.

Issue building OpenCV with ccache and CUDA

Trying to build OpenCV 3.3.1 with CUDA support, using ccache:
Ubuntu 16.04 LTS
OpenCV 3.3.1
CUDA 8.0
CCACHE 3.2.4
Make fails for .cu files, giving error:
/usr/bin/ccache: invalid option -- 'E'
Usage:
ccache [options] ...
I've added the /usr/lib/ccache to PATH, which cc and which c++ outputs /usr/lib/ccache/cc and /usr/lib/ccache/c++ respectively. Manually added a symlink for nvcc in /usr/lib/ccache directory, but now OpenCV CMakeLists.txt cannot find CUDA.
But interestingly I can build this sample CUDA code, with this CMake file without any issue.
I've searched the net and read most posts on SO and other forums, but had no success. I've had this issue for previous versions of OpenCV as well, but always disabled ccache as a solution.
Can someone please explain the reason behind this error?
Trying to set
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
seems to solve this problem for me.

Install openCV with CUDA toolkit 8.0

I'm trying to install Opencv 3.2.0 and Nvidia CUDA toolkit 8.0 on Ubuntu 16.04 but I can't configure them together. I get the following error when I try to make project using both:
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find CUDA: Found unsuitable version "8.0", but required is exact
version "7.5" (found /usr/local/cuda)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:386 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.5/Modules/FindCUDA.cmake:949 (find_package_handle_standard_args)
/usr/local/share/OpenCV/OpenCVConfig.cmake:86 (find_package)
/usr/local/share/OpenCV/OpenCVConfig.cmake:105 (find_host_package)
CMakeLists.txt:10 (find_package)
-- Configuring incomplete, errors occurred!
I have tried installing cuda toolkit 7.5 but its not compatible with ubuntu 16.04 I believe. I'm really clueless now, I hope someone can help with this.
Thanks
so I solved this issue by managing to install toolkit 7.5. Here is how I did it:
Updated nvidia driver for my Operating System
Download cuda toolkit 7.5 and extract it to a folder
$ mkdir ~/Downloads/NVIDIA_TOOLKIT
$ cd ~/Downloads
$ ./cuda_7.5.18_linux.run -extract=~/Downloads/NVIDIA_TOOLKIT;
go to the virtual console by pressing Ctrl + Alt + F1 and turn off
lightdm service
$ sudo service lightdm stop
cd to downloads and install the extracted toolkit and samples
$ cd ~/Downloads/NVIDIA_TOOLKIT
$ sudo ./cuda-linux64-rel-6.0.37-18176142.run
$ sudo ./cuda-samples-linux-6.0.37-18176142.run
Set environment variables in .bashrc file
$ PATH=/usr/local/cuda-7.5/bin
$ LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64
Turn back on the lightdm service
$ sudo service lightdm start
Reboot and you should be able to use the nvcc compiler
For openCV you will have to downgrade your gcc/ g++ compiler to 4.9 since it is not yet compatible with the higher versions

OpenCV 2.4.9 and CUDA 6.5

I recently upgraded to CUDA 6.5, and I recompiled succefully OpenCV 2.4.9 on Ubuntu 14.04.
However when I recompiled my project using OpenCV and cmake, I got the following configuration error:
-- GCC detected, adding compile flags
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find CUDA: Found unsuitable version "6.5", but required is exact
version "6.0" (found /usr/local/cuda-6.5)
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:313 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindCUDA.cmake:806 (find_package_handle_standard_args)
/usr/local/share/OpenCV/OpenCVConfig.cmake:215 (find_package)
CMakeLists.txt:9 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/andrey/Data/Projects/Groups_code/Lulu/build-Ubuntu/CMakeFiles/CMakeOutput.log".
How to fix this one? Do I need to reinstall cmake, or upgrade Modules file in cmake?
Try delete cmake cache.
"File"->"Delete Cache". Then "Configure" , "Generate" as usual.
In my experience, when OpenCV is built with a certain version of CUDA it specifies that in the file /usr/local/share/OpenCV/OpenCVConfig.cmake. If you have changed your version of CUDA after you built OpenCV then rebuilding OpenCV with the new CUDA version should fix this. That will basically rewrite the new version to /usr/local/share/OpenCV/OpenCVConfig.cmake.
In addition, it seems that you are calling find_package(CUDA) after calling find_package(OpenCV). That enforces cmake to look for the version of CUDA with which OpenCV was built. If you call find_package(CUDA) before find_package(OpenCV) you will likely see something like:
-- Found CUDA: /usr/local/cuda-6.5 (found version "6.5")
CMake Error at /usr/local/share/OpenCV/OpenCVConfig.cmake:222 (message):
OpenCV static library was compiled with CUDA 6.0 support. Please, use the
same version or rebuild OpenCV with CUDA 6.5
Call Stack (most recent call first):
CMakeLists.txt:49 (find_package)
OpenCV source has been changing over the years with different versions of CUDA and so a version mismatch there can cause things to break. So the recommended way to fix this is to rebuild OpenCV.

Resources