darktable

Update 7/2022: I recently upgraded to darktable 4.0 and was no longer able to get OpenCL working even though clinfo showed my GPU as successfully recognized. When I ran darktable -d opencl I got an error similar to the following:

[opencl_fopen_stat] could not open file `/home/user/.cache/darktable/cached_kernels_for_xxx/demosaic_ppg.cl.bin'!
[opencl_load_program] could not load cached binary program, trying to compile source
[opencl_build_program] could not build program: CL_BUILD_PROGRAM_FAILURE
[dt_opencl_device_init] failed to compile program `demosaic_ppg.cl'!

I wondered if the ROCm drivers I had been using were out-of-date or no longer compatible, so I removed the following three packages and installed the opencl-amd package instead:

pacman -R rocm-opencl-runtime rocr-runtime roct-thunk-interface

After doing this, clinfo still looked good and now I was successfully able to start darktable 4.0 with OpenCL working.


I recently purchased an AMD Raedon RX 570 GPU in order to accelerate Darktable processing operations using OpenCL. It looks like ROCm, AMD's open-source OpenCL implementation, should work. However, the process to install ROCm and enable image support on Arch Linux was not intuitive, so I'm documenting it here.

Before starting, make sure you have installed the open-source AMDGPU driver (via the xf86-video-amdgpu package).

Install the following ROCm packages from the AUR (I recommend using pacaur to make this easier):

  • rocm-opencl-runtime
  • rocr-runtime
  • roct-thunk-interface

At the time of this writing, hsa-ext-rocr is also required (as noted here), however the PKGBUILD is not up-to-date so use this one instead:

# Maintainer: Bruno Filipe <bmilreu@gmail.com>
pkgname=hsa-ext-rocr
pkgver=1.1.9
pkgrel=15
_debfile=hsa-ext-rocr-dev_1.1.9.0-rocm-rel-3.0-6-7128d0d_amd64.deb
pkgdesc="ROCm Platform Runtime: Closed source components"
arch=('x86_64')
url="https://github.com/RadeonOpenCompute/ROCm"
license=('EULA')
groups=()
depends=(rocm-opencl-runtime)
makedepends=()
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
replaces=()
backup=()
options=()
source=("http://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/${_debfile}")
sha256sums=('308bb895465562a2faf002970ffad3e9b204a21265032277e7b7bb1115caff5f')

package() {
        cd "$srcdir"
        tar xf data.tar.gz

        mkdir -p ${pkgdir}/usr/lib

        cp -ax opt/rocm/hsa/lib/* ${pkgdir}/usr/lib
}

After writing this PKGBUILD to a directory, run the following commands to build and install it:

makepkg
sudo pacman -U hsa-ext-rocr-1.1.9-15-x86_64.pkg.tar.xz

Finally, install these packages with pacman:

  • clinfo
  • ocl-icd

You may need to reboot, and then confirm that your graphics card is recognized and that image support is working:

$ clinfo | grep -iE 'Device Name|Image support' | head -n2
  Device Name                                     gfx803
  Image support                                   Yes

At this point, run darktable-cltest to confirm that Darktable can load the OpenCL drivers. If it reports success, you should be ready to enjoy the speed improvements with OpenCL.