AMD OpenCL Ubuntu 22.04 not working with Darktable

The “–no-dkms” parameter for the amdgpu-install command opts out of installing AMD’s proprietary (closed-source) drivers into your linux kernel. I believe the proprietary drivers are required for the legacy implementation of OpenCL.

If you’re struggling with the installation, you may want to read AMD’s documentation on installing the AMDGPU stack. There is a section specific to OpenCL that contains the commands I posted. The overview in the documentation also supports what @WmBrant said about ROCr OpenCL not supporting RX 500 or earlier cards.

Unfortunately, installing OpenCL often takes some fiddling and trial and error to get it installed correctly. The clinfo command is your friend. Focus on getting clinfo to see your graphics card first, and in all likelihood darktable will take care of itself after that. If you can see your card in clinfo and are still having problems, darktable has their own documentation on troubleshooting OpenCL.

2 Likes

I gave up with my AMD gpu (RX 5500 XT) 2 months ago after a year of no OpenCL on Linux/Darktable ( a major pain performance-wise even on a 12-core Ryzen), and many, many, many wasted weeks of fiddling/googling/installing/trying to fix. I concluded AMD driver support for Linux is too poor to commit any more of my time and my post-processing to any longer so I bought a Nvidia RTX 3070. After replacing the AMD and booting the OS (Mint 20.3 Cinnamon) I selected Install Nvidia drivers in the desktop drivers panel and 2 MINUTES later I had fully operational graphics and OpenCL, plus a very nice config/diagnostic gui! Plus no issues since, during which there have been 2 OS updates.

Prior to Autumn 2021, for about a year I had OpenCL from the AMDGPU-PRO package running alongside the open-source amdgpu drivers, on the workstation running OpenSuse Leap 15.1. It did take me quite a while to get the OpenCL installed as I found it needed a kernel several releases higher than the default Leap stable version. Importantly the AMD installer at that time did not recompile dkms (it used the --no-dkms option) and there was a reasonable amount of shared experience on the forums.

I guess a Leap 15.1 update Autumn 2021 time mangled some dependencies and caused OpenCL to start giving problems which after an upgrade to DT 3.8 would then freeze the system completely. Disable opencl in DT and everything was ok, so it was an Opencl issue.

I did a clean install of Leap 15.2 and installed the same version of AMDGPU-PRO OpenCL (ie the old installer). Installed ok but same freeze-ups. Back to no OpenCL.

I clean installed Leap 15.3 and the AMDGPU-PRO package marked ‘for Leap 15.3’ on the AMD website. This came with the new installer which DOES recompile dkms (hence the removal of the --no-dkms option). I found this installer downloads AMD own repository of kernel source code against which the specific version of the AMDGPU-PRO drivers have been tested, and mixes this code base with whatever version of the kernel you have installed when compiling/making dkms. What a surprise when it fails to compile/make because your kernel is too far behind (or ahead of) their sources! AMD don’t even mention which kernel version they tested against in their release notes. Also the kernel version you have affects other components that AMDGPU-PRO OpenCL needs but these version dependencies also aren’t mentioned (eg c-compiler version). Recipe for version-msimatch hell! I updated to the latest stable kernel and tried again but compile/make errors, now the kernel was too new! I eventually gave up and reverted to 15.2 .

Then I installed Mint 20.3 Cinnamon and the latest AMD package for that OS. It failed to compile dkms regardess of which kernel I tried. I didn’t have the time to waste so I went back to Leap 15.2 and no Opencl.

A major frustration is that most info on forums etc is out of date and not relevent to the new AMD install/compile process. But the lack of info on the AMD website is shocking. Nvidia have much, much more, and an install method that is built into Linux (at least the distros I’ve used). When I built the workstation early 2020, the general consensus of comments was that AMD were better than Nvidia for linux support, hence my choice of AMD gpu. A lot changes in a couple of years!

Good luck.

Thanks for sharing your experience.
My problem is that I cannot replace AMD with Nvidia as Its a dual boot system with macOS Big Sur and Ubuntu 22.04 and macOS only supports AMD GPUs.

Though openCL is working but now my Ubuntu will sometimes wake from suspend but mostly will freeze with black screen with only option to reboot.

After upgrading to v4, I invested some time to get OpenCL running on my RX560 on Linux Mint 21, based on Ubuntu 22.04. It was shortly before I was given an RX480 for cheap which is why I knew that once I get it going on the RX560, the RX480 will run plug’n’play as well. And it did.

To save you the time I had to invest:

  • the stock driver does not support opencl.
  • the rocm-opencl implementation established opengl recognition, but the missing “image” feature for those old Polaris chips ment that it was no use to darktable.
  • there is no need to install the “pro” version of AMD closed source driver using the use case “workstation”, opencl will be available in the “graphics” version as well, at least when installing it with the opencl flag.
  • the version on AMD website causes the mentioned package dependency errors and cannot be installed on Linux Mint 21 and maybe similar OS as well.
  • amd has a version of the drivers online that is only to be found when browsing the directories. It is newer than those linked on their main site and installs just fine in Linux Mint 21.

That driver can be found here:

https://repo.radeon.com/amdgpu-install/22.20.3/ubuntu/jammy/amdgpu-install_22.20.50203-1_all.deb

Best wishes,
Chris

1 Like

No updates on the driver? Opencl still broken with amdgpu.
*** The OpenCL driver doesn’t provide image support. See also ‘clinfo’ output ***
Using an old R390x that is supposed to be supported by the driver as it is specified on the released notes.
Tried all installing methods and driver versions and none have worked for me on ubuntu 22.04.1.

[dt_opencl_device_init]
DEVICE: 0: ‘AMD Radeon R9 390 Series (hawaii, LLVM 13.0.1, DRM 3.46, 5.15.0-52-generic)’
CANONICAL NAME: amdradeonr9390serieshawaiillvm1301drm346515052generic
PLATFORM NAME & VENDOR: Clover, Mesa
DRIVER VERSION: 22.0.5
DEVICE VERSION: OpenCL 1.1 Mesa 22.0.5
DEVICE_TYPE: GPU
*** The OpenCL driver doesn’t provide image support. See also ‘clinfo’ output ***
[opencl_init] no suitable devices found.
[opencl_init] FINALLY: opencl is NOT AVAILABLE on this system.
[opencl_init] initial status of opencl enabled flag is OFF.
[imageio_load_module_format] failed to open `avif’: (null)

Everything was working fine with 20.04!!!
Darktable without Opencl is almost unusable!

Well, the debugging output tells you the installed driver is missing the image support, this requirement did not change in dt.

I don’t know what Ubuntu did but for me the problem is either a) you didn’t install the driver correctly or b) Ubuntu did something wrong.

What does ‘clinfo’ tell you?

It seems to be a driver problem. Clinfo detects the gpu but spews out :
*** The OpenCL driver doesn’t provide image support. See also ‘clinfo’ output ***
Gpu works fine but no opencl support!!! Drivers installed correctly and user group permission video:render assigned properly.

Using amdgpu-install -y --usecase=graphics --opencl=legacy results in:
E: Unable to locate package clinfo-amdgpu-pro
E: Unable to locate package opencl-legacy-amdgpu-pro-icd

Using amdgpu-install --usecase=graphics,opencl results in:

The following additional packages will be installed:
amdgpu-core amdgpu-dkms-firmware comgr gst-omx-amdgpu hsa-rocr hsa-rocr-dev hsakmt-roct-dev libdrm-amdgpu-amdgpu1 libdrm-amdgpu-common libdrm-amdgpu-radeon1 libdrm-dev libdrm2-amdgpu libegl1-amdgpu-mesa
libegl1-amdgpu-mesa-drivers libelf-dev libgbm1-amdgpu libgl1-amdgpu-mesa-dri libgl1-amdgpu-mesa-glx libglapi-amdgpu-mesa libllvm14.0.50203-amdgpu libpciaccess-dev libtinfo5 libwayland-amdgpu-client0
libwayland-amdgpu-egl1 libwayland-amdgpu-server0 libxatracker2-amdgpu mesa-amdgpu-omx-drivers mesa-amdgpu-va-drivers mesa-amdgpu-vdpau-drivers rocm-core rocm-language-runtime rocm-ocl-icd rocm-opencl
xserver-xorg-amdgpu-video-amdgpu
Recommended packages:
libtxc-dxtn-s2tc0 | libtxc-dxtn0
E: Can’t find a source to download version ‘1.0.0.1-1271047’ of ‘gst-omx-amdgpu:amd64’

all done with the latest driver from amd repo:
amdgpu-install22_20.50203-1_all.deb

I thought rocM didn’t support imaging, which seems to be the problem.

Trying all the install methods to be able to use opencl in darktable with an old r390x.
Rocm does seem to have a problem with imaging even if the gpu is supported as detailed in the release papers.

CLinfo spew:

dlerror: libamdocl-orca64.so: cannot open shared object file: No such file or directory
Number of platforms 2
Platform Name Clover
Platform Vendor Mesa
Platform Version OpenCL 1.1 Mesa 22.0.5
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd
Platform Extensions function suffix MESA

Platform Name AMD Accelerated Parallel Processing
Platform Vendor Advanced Micro Devices, Inc.
Platform Version OpenCL 2.1 AMD-APP (3486.0)
Platform Profile FULL_PROFILE
Platform Extensions cl_khr_icd cl_amd_event_callback
Platform Extensions function suffix AMD
Platform Host timer resolution 1ns

Platform Name Clover
Number of devices 1
Device Name AMD Radeon ™ R9 390 Series (hawaii, LLVM 13.0.1, DRM 3.46, 5.15.0-52-generic)
Device Vendor AMD
Device Vendor ID 0x1002
Device Version OpenCL 1.1 Mesa 22.0.5
Device Numeric Version 0x401000 (1.1.0)
Driver Version 22.0.5
Device OpenCL C Version OpenCL C 1.1
Device Type GPU
Device Profile FULL_PROFILE
Device Available Yes
Compiler Available Yes
Max compute units 44
Max clock frequency 1080MHz
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 256
Preferred work group size multiple (kernel) 64
Preferred / native vector sizes
char 16 / 16
short 8 / 8
int 4 / 4
long 2 / 2
half 0 / 0 (n/a)
float 4 / 4
double 2 / 2 (cl_khr_fp64)
Half-precision Floating-point support (n/a)
Single-precision Floating-point support (core)
Denormals No
Infinity and NANs Yes
Round to nearest Yes
Round to zero No
Round to infinity No
IEEE754-2008 fused multiply-add No
Support is emulated in software No
Correctly-rounded divide and sqrt operations No
Double-precision Floating-point support (cl_khr_fp64)
Denormals Yes
Infinity and NANs Yes
Round to nearest Yes
Round to zero Yes
Round to infinity Yes
IEEE754-2008 fused multiply-add Yes
Support is emulated in software No
Address bits 64, Little-Endian
Global memory size 27487790692 (25.6GiB)
Error Correction support No
Max memory allocation 6871947673 (6.4GiB)
Unified memory for Host and Device No
Minimum alignment for any data type 128 bytes
Alignment of base address 32768 bits (4096 bytes)
Global Memory cache type None
Image support No
Local memory type Local
Local memory size 32768 (32KiB)
Max number of constant args 16
Max constant buffer size 67108864 (64MiB)
Max size of kernel argument 1024
Queue properties
Out-of-order execution No
Profiling Yes
Profiling timer resolution 0ns
Execution capabilities
Run OpenCL kernels Yes
Run native kernels No
ILs with version (n/a)
Built-in kernels with version (n/a)
Device Extensions cl_khr_byte_addressable_store 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_fp64 cl_khr_extended_versioning
Device Extensions with Version cl_khr_byte_addressable_store 0x400000 (1.0.0)
cl_khr_global_int32_base_atomics 0x400000 (1.0.0)
cl_khr_global_int32_extended_atomics 0x400000 (1.0.0)
cl_khr_local_int32_base_atomics 0x400000 (1.0.0)
cl_khr_local_int32_extended_atomics 0x400000 (1.0.0)
cl_khr_int64_base_atomics 0x400000 (1.0.0)
cl_khr_int64_extended_atomics 0x400000 (1.0.0)
cl_khr_fp64 0x400000 (1.0.0)
cl_khr_extended_versioning 0x400000 (1.0.0)

Platform Name AMD Accelerated Parallel Processing
Number of devices 0

NULL platform behavior
clGetPlatformInfo(NULL, CL_PLATFORM_NAME, …) No platform
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, …) No platform
clCreateContext(NULL, …) [default] No platform
clCreateContext(NULL, …) [other] Success [MESA]
clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT) Success (1)
Platform Name Clover
Device Name AMD Radeon ™ R9 390 Series (hawaii, LLVM 13.0.1, DRM 3.46, 5.15.0-52-generic)
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1)
Platform Name Clover
Device Name AMD Radeon ™ R9 390 Series (hawaii, LLVM 13.0.1, DRM 3.46, 5.15.0-52-generic)
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL) Success (1)
Platform Name Clover
Device Name AMD Radeon ™ R9 390 Series (hawaii, LLVM 13.0.1, DRM 3.46, 5.15.0-52-generic)

is part of the amdgpu-pro install which is not available anymore

This was what I concluded a couple weeks ago when I had this same issue. I run Ubuntu 22.04 w/Radeon RX580. It seems Nvidia GPUs are really expensive at the moment, but I am going to live with not having OpenCL until I buy an Nvidia card. I’m hoping the prices drop over the next couple months.

I wasted half of a day trying to get my AMD card to work with Open CL.

The last place I landed while trying to troubleshoot was an open issue on AMD’s Github issue tracker.

I did not really understand much in that thread. I don’t know what is ROCm, Polaris, or many other terms that keep coming up. What I did get from that thread is that a lot of people who know much more about GPUs than I do are frustrated at AMD’s crappy hardware support. So I figured, “If these people can’t figure it out, then I sure as hell can’t figure it out, either.” And that’s when I decided to get Nvidia and hope it works out better. For now I will live without OpenCL.

It’s ironic because AMD has a reputation for being linux-friendly and the last time I tried to use an Nvidia card with Linux (~8 years ago), I had to fight way too much to get that one working. I just built a new computer and went with all-AMD hardware for those reasons. Now AMD is giving me problems and I just installed an Nvidia card on another Linux machine and it went really smoothly. So my recent experience has been the opposite of what I expected.

I bought a 1050Ti 4gb a few months ago. They’re going for < $200 right now. Sure you’re not playing Cyberpunk in 4k with that card, but it gave darktable a good speed boost.

1 Like

I’ve been using linux for about 12 years. I have used both AMD and NVIDIA gpu’s. The biggest problem with linux is gpu drivers compatibility and the willingness of the manufacturers to provide valid drivers for unix systems. This is specially true for AMD. AMD gpu’s are cheaper but you will encounter problems in the future with the drivers specially with opencl. NVIDIA is more expensive, support is still as bad as AMD but they are more stable in user experience and they will support opencl in the future, they are in version 3 and AMD is still in version 2. I think my next gpu investment will be the opposite of the last one.

Try
install the deb package
sudo apt-get install ./amdgpu-install_22.20.50203-1_all.deb
install driver
amdgpu-install -y --usecase=graphics --opencl=legacy

FWIW, Not all Linux distributions are the same.

Using Fedora 36 and 37 (in beta, about to be released), darktable uses OpenCL on a recent AMD GPU (in my case, AMD RX 6700XT) after you install the rocm-opencl package. Aside from installing darktable — that’s all you need to do.

So, theoretically, it should work on other distributions too, like Ubuntu — but apparently (and sadly) it doesn’t. One of the AMD devs contributed and maintains the ROCm packages “unofficially” on Fedora, so that’s probably why it works so well in this distro. Hopefully someone sorts it out for Ubuntu (and others) too.

Here’s my darktable-cltest as a point of comparison:

$ darktable-cltest
[dt_get_sysresource_level] switched to 2 as `large'
  total mem:       32006MB
  mipmap cache:    4000MB
  available mem:   21879MB
  singlebuff:      500MB
  OpenCL tune mem: OFF
  OpenCL pinned:   WANTED
[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
[opencl_init] opencl_synch_cache: active module
[opencl_init] opencl library 'libOpenCL' found on your system and loaded
[opencl_init] found 1 platform
[opencl_init] found 1 device

[dt_opencl_device_init]
   DEVICE:                   0: 'gfx1031'
   CANONICAL NAME:           gfx1031
   PLATFORM NAME & VENDOR:   AMD Accelerated Parallel Processing, Advanced Micro Devices, Inc.
   DRIVER VERSION:           3452.0 (HSA1.1,LC)
   DEVICE VERSION:           OpenCL 2.0 
   DEVICE_TYPE:              GPU
   GLOBAL MEM SIZE:          12272 MB
   MAX MEM ALLOC:            10431 MB
   MAX IMAGE SIZE:           16384 x 16384
   MAX WORK GROUP SIZE:      256
   MAX WORK ITEM DIMENSIONS: 3
   MAX WORK ITEM SIZES:      [ 1024 1024 1024 ]
   ASYNC PIXELPIPE:          NO
   PINNED MEMORY TRANSFER:   WANTED
   MEMORY TUNING:            NO
   FORCED HEADROOM:          400
   AVOID ATOMICS:            NO
   MICRO NAP:                250
   ROUNDUP WIDTH:            16
   ROUNDUP HEIGHT:           16
   CHECK EVENT HANDLES:      128
   PERFORMANCE:              3.113406
   DEFAULT DEVICE:           NO
   KERNEL DIRECTORY:         /usr/share/darktable/kernels
   CL COMPILER OPTION:       -cl-fast-relaxed-math
   KERNEL LOADING TIME:       0.0370 sec
[opencl_init] OpenCL successfully initialized.
[opencl_init] here are the internal numbers and names of OpenCL devices available to darktable:
[opencl_init]		0	'gfx1031'
[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]		0	-1	0	0	-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]		0	0	0	0	0
[opencl_synchronization_timeout] synchronization timeout set to 200

And here’s the output of clinfo, as a text attachment (as it’s VERY verbose):
clinfo.txt (10.2 KB)

Notably, it does have image support. Here’s the relevant excerpt from clinfo:

  Image support                                   Yes
    Max number of samplers per kernel             29663
    Max size for 1D images from buffer            134217728 pixels
    Max 1D or 2D image array size                 8192 images
    Base address alignment for 2D image buffers   256 bytes
    Pitch alignment for 2D image buffers          256 pixels
    Max 2D image size                             16384x16384 pixels
    Max 3D image size                             16384x16384x8192 pixels
    Max number of read image args                 128
    Max number of write image args                8
    Max number of read/write image args           64

(This is on Fedora Linux 37 beta, Silverblue edition with rocm-opencl.)

I’m sorry that this doesn’t exactly help you all using Ubuntu, except to show that it can work on Linux and also as a comparison of when it is working. I hope it’s fixed soon for you.

Can you elaborate on the rocm-opencl? Just a dnf install rocm-opencl?

I use fedora 36 and recently dt started to work with the openCL on my amd CPU/GPU. It caused crashes on dt, so i disabled it and only use the Nvidia card.

Tried the latest drivers but still have a "can’t find amgpu-pro… " nonsense.

darktable-cltest
[dt_get_sysresource_level] switched to 2 as `large’
total mem: 32003MB
mipmap cache: 4000MB
available mem: 21877MB
singlebuff: 500MB
OpenCL tune mem: WANTED
OpenCL pinned: WANTED
[opencl_init] opencl related configuration options:
[opencl_init] opencl: ON
[opencl_init] opencl_scheduling_profile: ‘very fast GPU’
[opencl_init] opencl_library: ‘default path’
[opencl_init] opencl_device_priority: ‘/!0,//
[opencl_init] opencl_mandatory_timeout: 400
[opencl_init] opencl_synch_cache: active module
[opencl_init] opencl library ‘libOpenCL’ found on your system and loaded
dlerror: libamdocl-orca64.so: cannot open shared object file: No such file or directory
[opencl_init] found 2 platforms
[opencl_init] no devices found for Advanced Micro Devices, Inc. (vendor) - AMD Accelerated Parallel Processing (name)
[opencl_init] found 1 device