How to make OpenCL work on 14.10 + Nvidia 331.89 drivers?

I too was confounded by this perplexing problem until I found a series of forum posts bout Virtual Lighttable in which the participants do some debugging. It turns out that the NVIDIA drivers need a custom modprobe rule that is not installed by default with either nvidia-331 or the the opencl drivers. These rules are provided in the nvidia-modprobe package.

Here is a list of all of the packages you will need to get OpenCL working on Ubuntu 14.10 with NVIDIA drivers:

sudo apt-get install nvidia-331 nvidia-331-uvm nvidia-opencl-dev nvidia-modprobe

EDIT: In case anyone encounters a similar problem on Ubuntu 15.04 and the NVIDIA 346.59 drivers, the command to fix the issue is nearly identical:

sudo apt-get install nvidia-346 nvidia-346-uvm nvidia-opencl-dev nvidia-modprobe

Ubuntu 15.10

sudo apt-get install nvidia-352 nvidia-352-dev nvidia-prime nvidia-modprobe nvidia-opencl-dev
sudo ln -s /usr/include/nvidia-352/GL /usr/local/include
sudo ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 /usr/local/lib/libOpenCL.so

Then compile with:

gcc -o main main.c -lOpenCL

And use the header as:

#include <CL/cl.h>

Notes:

  • a minimal test program to try it out
  • find your GPU model: How do I find out the model of my graphics card?
  • test that the driver is working: How do I check if Ubuntu is using my NVIDIA graphics card?
  • do not install the nvidia-current package. It is old. Either apt-cache search nvidia and get the latest one, or use software-properties-gtk "Additional Drivers" tab.

I really recommend upgrading to 15.10 to get this to work: I had never managed before.

Tested on:

  • Lenovo ThinkPad T430 with NVIDIA NVS 5400M
  • Lenovo ThinkPad W540 with NVIDIA Quadro K1100M

Tags:

Opencl

Nvidia