OpenCV Error: Gpu API call (no CUDA-capable device is detected)
In case you are trying to use OpenCV with CUDA, you might first like to make sure that your OpenCV code is actually seeing the GPU.
So in the early part of your OpenCV code, you will have a small call like this:
cv::gpu::setDevice(0); cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
Running the code, you may receive an error message like the following:
OpenCV Error: Gpu API call (no CUDA-capable device is detected) in setDevice... terminate called after throwing an instance of 'cv::Exception'
And you are sure that the CUDA enabled graphics card is there.
There are a set of things to check when the above happens.
First,
- what is the output of nvidia-smi command. As root, run the command and make sure it is seeing your graphics card(s). If it is not showing any thing then there are problems with graphics card driver.
- in your CUDA installation, there is a utility application, usually located at /usr/local/cuda/samples/1_Utilities/deviceQuery , compile this application and make sure it runs fine. There is a makefile there to compile the application.
- make sure that the OpenCV is compiled correctly with CUDA support active. For this, at the time of running cmake-gui go through the options and make sure that it has found your CUDA installation and it is showing the correct version info. If it is not happening, make sure that your CUDA_HOME environment variable is set and is pointing to a correct address (usually /usr/local/cuda) and also the bin folder of CUDA installation is in the PATH.
- make sure that the permission for /dev/nvidia* nodes are correct so that normal users can have also access to these nodes. In order to check that, the first thing you may like to do is to run your OpenCV application with root instead of a normal user account.
Leave a Reply