AMD OpenCL Ubuntu 22.04 not working with Darktable

DEVICE_TYPE: GPU *** The OpenCL driver doesn’t provide image support. See also ‘clinfo’ output ***

I’ve built the rustical driver from the Karol Herbst’s sources, i.e

Karol Herbst / mesa · GitLab branch rusticl/si

It took a bit until all the required tools and libraries were installed on my Ubuntu 22.04 system before the build went through.
When the driver is installed you need to set the environment varable to

RUSTICL_ENABLE=radeonsi

With this environement set the amdgpu is recognized … unfortunately I have issues: Some images are completely black and I was not able yet to find out why. I suppose it’s some issues with the llvm version. I’ll try whether I am abel to compile and link against llvm-15

Short follow up: I was now able to compile against llvm-15 but still no luck. My situation is exactly as described by @matze in Draft: Support Radeonsi with Rusticl (!19232) · Merge requests · Mesa / mesa · GitLab

1 Like

AMD new driver 22.20.50205-1_all

I have not tried it yet but this is dated 28 Nov 2022.

I am NO expert on Linux, I am a newbie but I experiment different things and put my findings here which works for me. So please backup your system before experimenting.

The above version works perfectly for me.

Ubuntu 22.04.1 LTS
kernel 5.15.0-56-generic
i7-8700k & AMD RX-570
Graphics: clinfo (relevant part)
Platform Name AMD Accelerated Parallel Processing
Platform Vendor Advanced Micro Devices, Inc.
Platform Version OpenCL 2.1 AMD-APP (3380.4)
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd cl_amd_event_callback cl_amd_offline_devices
Platform Extensions function suffix AMD
Platform Host timer resolution 1ns

Platform Name Intel(R) OpenCL HD Graphics
Number of devices 1
Device Name Intel(R) UHD Graphics 630 [0x3e92]
Device Vendor Intel(R) Corporation
Device Vendor ID 0x8086
Device Version OpenCL 3.0 NEO

Both my openCL devices are recognized by darktable-cltest.
[opencl_init] 0 ‘Intel(R) UHD Graphics 630 [0x3e92]’
[opencl_init] 1 ‘Ellesmere’
[opencl_init] FINALLY: opencl is AVAILABLE on this system.
[opencl_init] initial status of opencl enabled flag is ON.
[dt_opencl_update_priorities] these are your device priorities:
[dt_opencl_update_priorities] image preview export thumbs preview2
[dt_opencl_update_priorities] 1 0 1 0 0
[dt_opencl_update_priorities] -1 -1 0 1 1
[dt_opencl_update_priorities] show if opencl use is mandatory for a given pixelpipe:
[dt_opencl_update_priorities] image preview export thumbs preview2
[dt_opencl_update_priorities] 1 0 1 1 1
[opencl_synchronization_timeout] synchronization timeout set to 200

Decided to give up on AMD and moved on to NVIDIA. Current GPU prices are just stupid. Managed to get my hands on a GTX3080 10G. Installation of drivers in one click, everything installed nicely and hassle free. Performance is top notch compared to amd opencl dated stack. Thank you all for your help!

1 Like

After mesa 23.1 got the rusticl drivers merged, I wanted to give it a try with darktable again. The driver is being detected within darktable but it’s marked as “disabled” … I have no idea why and what I am probably doing wrong …
darktable-cltest gives me

RUSTICL_ENABLE=radeonsi /opt/darktable/bin/darktable-cltest 
     0.0582 [dt_get_sysresource_level] switched to 2 as `large'
     0.0582   total mem:       31460MB
     0.0582   mipmap cache:    3932MB
     0.0582   available mem:   21505MB
     0.0582   singlebuff:      1966MB
     0.0582   OpenCL tune mem: OFF
     0.0582   OpenCL pinned:   OFF
[opencl_init] opencl related configuration options:
[opencl_init] opencl: ON
[opencl_init] opencl_scheduling_profile: 'multiple GPUs'
[opencl_init] opencl_library: 'default path'
[opencl_init] opencl_device_priority: '!0,*/!1,*/1,*/1,*'
[opencl_init] opencl_mandatory_timeout: 2000
     0.0589 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL'
     0.0590 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL.so'
[opencl_init] opencl library 'libOpenCL.so.1' found on your system and loaded
[opencl_init] found 3 platforms
[opencl_init] found 3 devices

[dt_opencl_device_init]
   DEVICE:                   0: 'AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.1.0-1008-oem)'
   CANONICAL NAME:           amdradeongraphicsrenoirllvm1507drm3496101008oem
   PLATFORM NAME & VENDOR:   Clover, Mesa
   DRIVER VERSION:           23.1.0-devel
   DEVICE VERSION:           OpenCL 1.1 Mesa 23.1.0-devel (git-55c9356 2023-04-13 jammy-oibaf-ppa)
   DEVICE_TYPE:              GPU
   *** The OpenCL driver doesn't provide image support. See also 'clinfo' output ***

[dt_opencl_device_init]
   DEVICE:                   1: 'AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.1.0-1008-oem)'
   CANONICAL NAME:           amdradeongraphicsrenoirllvm1507drm3496101008oem
   PLATFORM NAME & VENDOR:   rusticl, Mesa/X.org
   DRIVER VERSION:           23.1.0-devel (git-45826e42c5)
   DEVICE VERSION:           OpenCL 3.0 
   DEVICE_TYPE:              GPU
   GLOBAL MEM SIZE:          15730 MB
   MAX MEM ALLOC:            2048 MB
   MAX IMAGE SIZE:           16384 x 16384
   MAX WORK GROUP SIZE:      1024
   MAX WORK ITEM DIMENSIONS: 3
   MAX WORK ITEM SIZES:      [ 1024 1024 1024 ]
   ASYNC PIXELPIPE:          NO
   PINNED MEMORY TRANSFER:   NO
   MEMORY TUNING:            NO
   FORCED HEADROOM:          400
   AVOID ATOMICS:            NO
   MICRO NAP:                250
   ROUNDUP WIDTH:            16
   ROUNDUP HEIGHT:           16
   CHECK EVENT HANDLES:      128
   TILING ADVANTAGE:         0.000
   DEFAULT DEVICE:           NO
   *** marked as disabled ***

[dt_opencl_device_init]
   DEVICE:                   2: 'NVIDIA GeForce RTX 3060 Laptop GPU'
   CANONICAL NAME:           nvidiageforcertx3060laptopgpu
   PLATFORM NAME & VENDOR:   NVIDIA CUDA, NVIDIA Corporation
   DRIVER VERSION:           515.105.01
   DEVICE VERSION:           OpenCL 3.0 CUDA, SM_20 SUPPORT
   DEVICE_TYPE:              GPU
   GLOBAL MEM SIZE:          5947 MB
   MAX MEM ALLOC:            1487 MB
   MAX IMAGE SIZE:           32768 x 32768
   MAX WORK GROUP SIZE:      1024
   MAX WORK ITEM DIMENSIONS: 3
   MAX WORK ITEM SIZES:      [ 1024 1024 64 ]
   ASYNC PIXELPIPE:          NO
   PINNED MEMORY TRANSFER:   NO
   MEMORY TUNING:            NO
   FORCED HEADROOM:          0
   AVOID ATOMICS:            NO
   MICRO NAP:                250
   ROUNDUP WIDTH:            16
   ROUNDUP HEIGHT:           16
   CHECK EVENT HANDLES:      128
   PERFORMANCE:              1.949
   TILING ADVANTAGE:         0.000
   DEFAULT DEVICE:           NO
   KERNEL BUILD DIRECTORY:   /opt/darktable/share/darktable/kernels
   KERNEL DIRECTORY:         /home/ds/.cache/darktable/cached_v1_kernels_for_NVIDIAGeForceRTX3060LaptopGPU_51510501
   CL COMPILER OPTION:       -cl-fast-relaxed-math
   KERNEL LOADING TIME:       0.0167 sec
[opencl_init] OpenCL successfully initialized. Internal numbers and names of available devices:
[opencl_init]		0	'NVIDIA GeForce RTX 3060 Laptop GPU'
[opencl_init] FINALLY: opencl is AVAILABLE and ENABLED.

Anybody got an idea?

There are multiple opencl drivers working and cuda is picked over rustcl.

yes, there are three different *.icd files … but even if I remove te other ones and leave only ruscticl.icd to force usage of the rusticl driver, the driver is marked as “disabled” and opencl is no longer available at all.

The issue is that mesa installs both clover and rusticl opencl implementation and enables both of them (mesa.icd and rusticl.icd in /etc/OpenCL/vendors`).
The device names provided by them are the same and darktable generates the same cldevice_v4 key. So when darktable disables the clover device it writes this key marking the device as disabled, and this will also affects the rusticl device since it has the same name.

A possible solution (worked for me) is to disable clover and use only rusticl and clean darktablerc.

  • Remove /etc/OpenCL/vendors/mesa.icd to disable clover
  • Clean darkktablerc removing the entries starting with cldevice_v4_DEVICENAME

Then rerun darktable-cltest and it should work

@hannoschwalm Do you think it will be feasible to use also the platform name in the cldevice key? Probably this deserves a github issue.

2 Likes

@sgotti Simone i think your analysis is absolutely correct and would explain isues here plus some reported issues on github. Congrats!

Even if not all problems might be solved by doing so, i would absolutely support including the platform name in cldevice.

Will you do the pr and i would review? (I would prefer that as i have no amd system available and can’t test at all)

2 Likes

The rusticl drivers are detected now:

[dt_opencl_device_init]
   DEVICE:                   0: 'AMD Radeon Graphics (renoir, LLVM 15.0.7, DRM 3.49, 6.1.0-1008-oem)', NEW
   CANONICAL NAME:           amdradeongraphicsrenoirllvm1507drm3496101008oem
   PLATFORM NAME & VENDOR:   rusticl, Mesa/X.org
   DRIVER VERSION:           23.1.0-devel (git-45826e42c5)
   DEVICE VERSION:           OpenCL 3.0 
   DEVICE_TYPE:              GPU
   GLOBAL MEM SIZE:          15730 MB
   MAX MEM ALLOC:            2048 MB
   MAX IMAGE SIZE:           16384 x 16384
   MAX WORK GROUP SIZE:      1024
   MAX WORK ITEM DIMENSIONS: 3
   MAX WORK ITEM SIZES:      [ 1024 1024 1024 ]
   ASYNC PIXELPIPE:          NO
   PINNED MEMORY TRANSFER:   NO
   MEMORY TUNING:            NO
   FORCED HEADROOM:          400
   AVOID ATOMICS:            NO
   MICRO NAP:                250
   ROUNDUP WIDTH:            16
   ROUNDUP HEIGHT:           16
   CHECK EVENT HANDLES:      128
   TILING ADVANTAGE:         0.000
   DEFAULT DEVICE:           NO
   KERNEL BUILD DIRECTORY:   /opt/darktable/share/darktable/kernels
   KERNEL DIRECTORY:         /home/ds/.cache/darktable/cached_v1_kernels_for_AMDRadeonGraphicsrenoirLLVM1507DRM3496101008oem_2310develgit45826e42c5
   CL COMPILER OPTION:       -cl-fast-relaxed-math
   KERNEL LOADING TIME:       0.3564 sec

unfortunately it’s crashing with:
darktable: ../src/gallium/drivers/radeonsi/si_buffer.c:350: si_buffer_transfer_map: Assertion box->x + box->width <= resource->width0’ failed.`

I’ll try to prepare a PR, I’ll have some time next week if it’s not too late for you.

I just built mesa from 23.1 branch on archlinux. It doesn’t crash but some modules (color balance RGB, demosaic markesteijn) create black images (like already reported on the related mesa gitlab issue).

5 Likes

I thought I waited sufficiently until the newest ANDGPU drivers, Installed their September 6th version for Ubuntu 22.04 LTS. With the Vulkan SDK 1.3.250 - it should not be relevant to OpenCL, but was an issue on a previous build.

On this system Darktable 4.4.2 installed under flatpak.

As a result of all of it, I have OpenCL 2.0 reported by clinfo:

$ clinfo | grep -Ei "^\s+device" | sort -b -u
  Device Available                                Yes
  Device Board Name (AMD)                         Radeon RX 7900 XT
  Device Extensions                               cl_khr_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_gl_sharing cl_amd_device_attribute_query cl_amd_media_ops cl_amd_media_ops2 cl_khr_image2d_from_buffer cl_khr_subgroups cl_khr_depth_images cl_amd_copy_buffer_p2p cl_amd_assembly_program 
  Device Name                                     gfx1100
    Device Name                                   gfx1100
  Device OpenCL C Version                         OpenCL C 2.0 
  Device Partition                                (core)
  Device PCI-e ID (AMD)                           0x744c
  Device Profile                                  FULL_PROFILE
  Device Topology (AMD)                           PCI-E, 0000:03:00.0
  Device Type                                     GPU
  Device Vendor                                   Advanced Micro Devices, Inc.
  Device Vendor ID                                0x1002
  Device Version                                  OpenCL 2.0 
$ ls -l /dev/dri/render*
crw-rw----+ 1 root render 226, 128 Sep 24 22:13 /dev/dri/renderD128
$ groups
vlad adm cdrom sudo dip plugdev render lpadmin lxd sambashare
$

The darktable fails to use OpenCL nonetheless, claiming “insufficient device version” which makes no sense as it reports OpenCL 1.1, not the 2.0 as clinfo:

$ flatpak run org.darktable.Darktable -d opencl
Gtk-Message: 22:24:48.649: Failed to load module "canberra-gtk-module"
Gtk-Message: 22:24:48.651: Failed to load module "canberra-gtk-module"
     0.8202 [dt_get_sysresource_level] switched to 2 as 'large'
     0.8202   total mem:       128643MB
     0.8202   mipmap cache:    16080MB
     0.8202   available mem:   87940MB
     0.8202   singlebuff:      2010MB
     0.8202   OpenCL tune mem: OFF
     0.8202   OpenCL pinned:   OFF
[opencl_init] opencl related configuration options:
[opencl_init] opencl: ON
[opencl_init] opencl_scheduling_profile: 'default'
[opencl_init] opencl_library: 'default path'
[opencl_init] opencl_device_priority: '*/!0,*/*/*/!0,*'
[opencl_init] opencl_mandatory_timeout: 200
     0.8263 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL'
     0.8263 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL.so'
[opencl_init] opencl library 'libOpenCL.so.1' found on your system and loaded
[opencl_init] found 1 platform
[opencl_init] found 1 device

[dt_opencl_device_init]
   DEVICE:                   0: 'AMD Radeon RX 7900 XT (gfx1100, LLVM 15.0.7, DRM 3.54, 6.2.0-33-generic)'
   PLATFORM NAME & VENDOR:   Clover, Mesa
   CANONICAL NAME:           cloveramdradeonrx7900xt
   DRIVER VERSION:           23.1.6
   DEVICE VERSION:           OpenCL 1.1 Mesa 23.1.6 (git-0697ac0d75)
   DEVICE_TYPE:              GPU
   *** insufficient device version ***
[opencl_init] no suitable devices found.
[opencl_init] FINALLY: opencl is NOT AVAILABLE and NOT ENABLED.

Can someone, please, look at it and help point out what I miss?

Flatpak does not use your system’s GPU driver. It has its own. Last I checked, which was a while ago, there wasn’t a package for AMDGPU pro.

1 Like

Yes, that seems to be it - thank you for the pointer.

With that there seems to be no good packaged way to run DT 4.4.* with OpenCL on Linux at the moment. Good to know, let me downgrade to Suse-built 4.2

https://software.opensuse.org/download.html?project=graphics:darktable&package=darktable

2 Likes

Oh, that is recent ;), nice

Your system is already recognising OpenCL. DO NOT install anything ROCM. It will break your darktable system and make it very unstable. This entry on the Arch forum may help:
[SOLVED/WORKAROUND] Darktable rusticl AMD Radeon Graphics error messag / Multimedia and Games / Arch Linux Forums and this one: Opencl error (may be PHI node, LLVM problem) / Multimedia and Games / Arch Linux Forums.
Also, perhaps take a look at the GPGPU article on the Arch wiki.

It is now a year since this post was generated. OpenCL AFAIK now runs cleanly on every distro. There is a klutz with Arch and AMD, in that DT should be started from the command line and with a preamble. My first link above shows how. It is very easy.

SORRY THAT WAS ALL NONSENSE. I went back into DT after making this post and used the Darkroom. It turned the images in the workspace black and I couldn’t do anything with them. They are OK, the thumbnails re still there and there is a brief flash of each image as it loads. But impossible to work on them.

AUR (en) - opencl-amd works just fine on arch

1 Like

I try to avoid AUR until alternatives have been exhausted. AUR packages are very easy to install but updating later is confusing.

Having said that, AUR to the rescue here. Just installed opencl-amd and it is faultless.

Getting DT from Lighttable to Darkroom is excrutiotingly slow but with a couple of settings tweaks the speed has already improved a bit. I need to do a thorough revision of what the installation has done to the settings but it should all work out OK.

Otherwise I’ll switch the GPU off altogether.