darktable logo

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:

1[opencl_fopen_stat] could not open file `/home/user/.cache/darktable/cached_kernels_for_xxx/demosaic_ppg.cl.bin'!
2[opencl_load_program] could not load cached binary program, trying to compile source
3[opencl_build_program] could not build program: CL_BUILD_PROGRAM_FAILURE
4[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:

1pacman -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 from the AUR is also required (as noted here), however the PKGBUILD is not up-to-date so use this one instead:

 1# Maintainer: Bruno Filipe <bmilreu@gmail.com>
 2pkgname=hsa-ext-rocr
 3pkgver=1.1.9
 4pkgrel=15
 5_debfile=hsa-ext-rocr-dev_1.1.9.0-rocm-rel-3.0-6-7128d0d_amd64.deb
 6pkgdesc="ROCm Platform Runtime: Closed source components"
 7arch=('x86_64')
 8url="https://github.com/ROCm/ROCm"
 9license=('EULA')
10groups=()
11depends=(rocm-opencl-runtime)
12makedepends=()
13provides=("${pkgname%-git}")
14conflicts=("${pkgname%-git}")
15replaces=()
16backup=()
17options=()
18source=("https://repo.radeon.com/rocm/apt/debian/pool/main/h/hsa-ext-rocr-dev/${_debfile}")
19sha256sums=('308bb895465562a2faf002970ffad3e9b204a21265032277e7b7bb1115caff5f')
20
21package() {
22        cd "$srcdir"
23        tar xf data.tar.gz
24
25        mkdir -p ${pkgdir}/usr/lib
26
27        cp -ax opt/rocm/hsa/lib/* ${pkgdir}/usr/lib
28}

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

1makepkg
2sudo 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:

1$ clinfo | grep -iE 'Device Name|Image support' | head -n2
2  Device Name                                     gfx803
3  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.


Support Us

If you found this article helpful, please subscribe to our newsletter or support us on Patreon and get access to bonus features!

Questions? Comments?

Do you have questions or comments about this article? Please contact us via Mastodon or Email - we want to hear from you!