Installing OpenCV 3.0.0 with NVIDIA CUDA 7.5 on Ubuntu 14.04 64bit

Installing OpenCV with NVIDIA CUDA is useful if you plan to run computationally intensive image processing algorithms. These are the steps I had to follow to install OpenCV 3.0.0 with CUDA 7.5.

The latest NVIDIA driver should be installed on your PC. Do not download the driver from NVIDIA because you might run into issues such as login screen loops. Instead, install it from the Ubuntu Repositories using the following command,

sudo apt-get install nvidia-current

Now download the cuda deb[network] file from

and follow the installation instructions

  1. sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
  2. sudo apt-get update
  3. sudo apt-get install cuda

If you don’t run into any problems, your CUDA installation now complete. Now you can proceed to OpenCV installation.

First you need to install the dependencies,

sudo apt-get install cmake cmake-curses-gui git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

While installing the dependencies, apt-get might refuse to install some dependencies if they are outdated. Then you just have to find the new versions and install them instead. After installing the dependencies, download OpenCV source. You may make a ‘opencv’  folder in home directory for keeping the source and building the binaries. Go to opencv git repository  and download the source to ~/opencv.

Now open a terminal. And run the following commands.

cd ~/opencv
mkdir build
cd build
ccmake .

I like to use ccmake instead of cmake since it allows me to configure the installation easily. You can select what packages you want to be installed in your PC. I have uploaded screenshots of my configuration.

With_TBB must be set to ON for PC in order to utilize all cores on your CPU for OpenCV programs. Build_TBB should be set to OFF for PC. WITH_CUDA must be set to ON to enable GPU support. The rest of the CUDA settings that are generated automatically by your configuration will be usually correct since you already installed CUDA.

Most of the time you will be compiling only for the GPU architecture of your GPU, so there is a option to select the GPU architecture ‘CUDA_ARCH_BIN’. Set the parameter equal to the compute capability of your GPU. This will greatly reduce the compilation time.

After you configure your installation, compile and install it using,

make -j $(nproc)
sudo make install

Try some OpenCV examples that use GPU acceleration. It is possible that some algorithms might run slower on GPU compared to running on the CPU. One possible reason is the time that it takes to transfer the image data, etc to the GPU. Another possible reason would be your GPU is in power saving mode. Check the powermizer settings in NVIDIA X Server Settings.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s