Ask Your Question

Revision history [back]

So I get back to you with the solution. First of all, the PR itself did not really break it, but rather you should make sure that your system is set up correctly. Had the same issue of cuda_runtime.h not being found, but doing the following steps clearly fixed it for me. I am on Ubuntu, but it will probably be quite similar on other systems.

  1. Clean up your system. This means going to /usr/local/ and simply deleting all folders containing cuda in their name. This will make sure old versions are completely gone. Do the same at your home location /home/username/ because samples and such tend to go there for a specific installation.
  2. Get yourself the latest stable NVIDIA CUDA installer, which was CUDA7.5 for me.
  3. Run the installer AND run the included video driver. If there is a mismatch between these two, it might jug up your CUDA installation making it not run smooth. Also install the CUDA samples, so you are sure CUDA is working properly on your system. [NOTE: I took all default paths, if you change them, you will need to change everything accordingly]

Before we can continue to OpenCV, we need to make sure that our system is fully configured for using CUDA.

  1. Go to /etc/ld.so.conf.d
  2. Inside the folder, make a file called cuda.conf and inside add this rule /usr/local/cuda/lib64
  3. Save the file and run sudo ldconfig
  4. Go to your home directory and edit the .bashrc file, adding both export PATH="$PATH:/usr/local/cuda/bin" and export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib at the end of the file. This will simply make sure that every time you open a terminal, that your system knows where CUDA can be found.

Now you can go get the latest OpenCV 3 master branch from github. When running cmake it will look for the installation and find the CUDA7.5 installation normally. It is very important that you check this. If it does not, run the cmake-gui installer and manually set the paths to your installation.

Now you are all set up. However there are still 2 important things to do

  1. If you are using an IDE or gcc/g++, do not forget to add -L /usr/local/cuda/lib64 to your linker settings.
  2. Add the following folders to your compiler search directions /usr/local/cuda/lib64 and /usr/local/lib/.

Using these guidelines every OpenCV GPU sample will build and run. The suggested opencv.hpp header expansion was partially undone, but there is a new PR going in to add the CUDA modules none the less, so if this above is set up correctly, the header will work just fine again!