3

OK, I have a pretty specific Optimus/CUDA/drivers question:

  • I'm running Ubuntu 12.04 on an Acer Aspire 5750G. This laptop has a CUDA-capable GT540M GPU, but it also has Optimus, so in order to make use of it I need to use bumblebee

  • Following these instructions I installed more recent NVIDIA drivers from ppa:ubuntu-x-swat/x-updates, then installed bumblebee

  • I can now run stuff on the GPU just fine (optirun glxspheres works as expected)

  • However, I'm trying to compile something (OpenCV-2.4.2) with CUDA runtime support, and I hit a compiler error that seems to be to do with not having the NVIDIA CUDA developer drivers installed

What I want to know is whether it's possible to use bumblebee in combination with the NVIDIA developer drivers. Is it safe to use the installer downloaded from NVIDIA's developer page, or will that totally mess up bumblebee? Is there a better way to install the developer drivers? I looked for an up-to-date PPA but couldn't find one.

Hennes
  • 65,804
  • 7
  • 115
  • 169
ali_m
  • 756

1 Answers1

4

Ok, so it turns out that I don't need to use the developer drivers to compile OpenCV after all!

I had somehow messed up my software sources such that I wasn't updating from ppa:ubuntu-x-swat/x-updates any more. When I fixed that I was able to update my NVIDIA drivers to 304.43 from 295.49. I think that might have been the critical factor for getting OpenCV to compile, although I did also have to modify one makefile to make it work.

If anyone's interested in doing the same, I basically followed the instructions here. To paraphrase:

  • sudo apt-get install the following module dependencies if you don't already have them:

    libopencv-dev build-essential checkinstall cmake pkg-config libtiff4-dev libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libv4l-dev

  • Download the latest OpenCV from here, then:

    tar -xvf OpenCV-<version#>.tar.bz2
    cd OpenCV-<version#>/
    mkdir build
    cd build
    
  • Run cmake to configure a build file. You will need to pass cmake a set of options to specify how you would like OpenCV to be built. The exact options will depend on your system - you can get some idea of what options are available by looking at ../CMakeLists.txt. The exact command I used was:

    cmake -D WITH_QT=ON -D WITH_XINE=ON -D WITH_OPENGL=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON BUILD_TESTS=ON  ENABLE_SSE3=ON ENABLE_SSE4.1=ON ENABLE_SSE4.2=ON WITH_CUDA=ON ..
    

    I had particular trouble getting it to compile with CUDA runtime support (WITH_CUDA=ON), hence the original question about the drivers.

  • cmake will create a file called CMakeCache.txt. I found that I had to modify this file as described here in order to avoid an error linking libcuda.so.

    Find the line that starts:

    CUDA_CUDA_LIBRARY:FILEPATH=
    

    And append the path to libcuda.so, in my case:

    CUDA_CUDA_LIBRARY:FILEPATH=/usr/lib/nvidia-current/libcuda.so
    
  • Now you should be able to run make to compile (takes a while...), then sudo make install to install

I hope somebody finds this useful.

ali_m
  • 756