Darktable, OpenCL, nVidia, Ubuntu 14.04, Mint 17

Submitted by kofa on Tue, 07/29/2014 - 21:45

Previously working configurations have been broken by upgrading to driver 367.44, resulting in

[opencl_init] could not create context for device 0: 209
[opencl_init] FINALLY: opencl is NOT AVAILABLE on this system.
[opencl_init] initial status of opencl enabled flag is OFF.

The solution was to install libnvidia-ptxjitcompiler - see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=839193

Summarising the discussion on darktable-users mailing list (main contributors to the solution were Ulrich Pegelow and Federico Bruni): darktable lost access to OpenCL upon upgrading to Ubuntu 14.04 ('trusty thar') or Linux Mint 17. Here's how to get it up to speed again:

Some older versions of nVidia drivers fail to compile darktable's OpenCL kernels (files that contain the GPU-accelerated image operations). You'll find updated versions here:

Now, in order to make use of said OpenCL kernels, darktable needs the system library libOpenCL.so which must be accessible to the system's dynamic loader (ld.so). Reason is that the function flow is like this:
darktable -> libOpenCL.so -> libnvidia-opencl.so.1 -> kernel driver -> hardware

And here is where each item in that flow can be installed:

  • libOpenCL.so is contained in nvidia-opencl-dev
  • libOpenCL.so will read the vendor-specific information file (ICD file) to find the library which contains the (vendor-specific) implementation.
    nvidia-opencl-icd-* contains both /etc/OpenCL/vendors/nvidia.icd and the library libnvidia-opencl.so.1 it points to.
    On my system, /usr/lib/x86_64-linux-gnu/libnvidia-opencl.so.1 is a symbolic link to libnvidia-opencl.so.331.89, which is the actual implementation.
  • The required kernel modules are nvidia and nvidia_uvm; they are provided by the packages nvidia-331 and nvidia-331-uvm, respectively.

You also need device files (/dev/nvidia*). The easiest way to set them up and make sure all modules are loaded is installing the nvidia-modprobe package (which, at the time of this writing, is only available for 'utopic', but works well with 'trusty' and Mint 17). Grab it at http://packages.ubuntu.com/utopic/nvidia-modprobe

To summarise, the packages I have installed are:

  • nvidia-331 / 331.89-0ubuntu1~xedgers14.04.2
  • nvidia-331-dev / 331.89-0ubuntu1~xedgers14.04.2
  • nvidia-331-uvm / 331.89-0ubuntu1~xedgers14.04.2
  • nvidia-libopencl1-331 / 331.89-0ubuntu1~xedgers14.04.2
  • nvidia-modprobe / 340.24-1
  • nvidia-opencl-dev:amd64 / 5.5.22-3ubuntu1
  • nvidia-opencl-icd-331 / 331.89-0ubuntu1~xedgers14.04.2
  • nvidia-settings / 340.24-0ubuntu1~xedgers14.04.1
  • nvidia-settings-304 / 340.24-0ubuntu1~xedgers14.04.1
  • nvidia-libopencl1-331 / 331.89-0ubuntu1~xedgers14.04.2
  • nvidia-opencl-dev:amd64 / 5.5.22-3ubuntu1
  • nvidia-opencl-icd-331 / 331.89-0ubuntu1~xedgers14.04.2
  • opencl-headers / 1.2-2013.10.23-1

My list of nvidia-related kernel modules (lsmod):

  • nvidia
  • nvidia_uvm

My nvidia-related device files (ls -l /dev/nvidia*):

  • crw-rw-rw- 1 root root 195, 0 Jul 28 21:13 /dev/nvidia0
  • crw-rw-rw- 1 root root 195, 255 Jul 28 21:13 /dev/nvidiactl
  • crw-rw-rw- 1 root root 250, 0 Jul 28 21:13 /dev/nvidia-uvm