How to enable OpenCL/OpenCL ROCm for AMD RX 570/580 on Ubuntu 23.04

I am really struggling to install OpenCL I tried the latest MESA driver from

sudo add-apt-repository ppa:kisak/kisak-mesa
But this driver doesn’t have image support so DT is not able to use it.
AMD provides drivers for Ubuntu LTS versions only like 20.04 and 22.04. So cannot install on 23.04

Someone suggested to use AMD ROCm but I am unable to understand how to install it in 23.04.

Can someone please guide me with commands and steps to make it work please?
Thanks

@Rajkhand,

I believe that the dilemma is to find someone who has
'buntu, AMD drivers, and RX570/580 :frowning:

I do not have those. But perhaps you can find out what
works in another way: do you have a spare SSD drive
(a smallish 120 gig will be sufficient), plus a small (8 or 4 gig)
USB stick?

If so it will be quite easy (and a fast operation, as well) to
install a special Linux distro, the drivers you need, openCL,
and darktable. In this way you can see what works without
having to disrupt your present 'buntu installation.

Have fun!
Claes in Lund, Sweden

I am not very eperienced with Linix but on my system the Nivida drivers installed with Linux mint did not support OpenCL. I had to install the genuine Nividia drvers and then I had to reinstall DT to get it to work. There were probably easier ways to handle the problem , but that worked for me. Good luck.

Install the AMD proprietary driver.

you do not need the full driver. just rocm is enough.

1 Like

One way would be to go to AMD website (AMD Documentation - Portal) and download amdgpu-install_5.5.50500-1_all.deb

Install downloaded package, which will add AMD ROCm repositories. After that all you need for OpenCL is to apt install rocm-opencl-runtime.

This works on Ubuntu 23.04. Whether it supports the old 580, I don’t know…

Did as you suggested, installed without errors.
darktable-cltest gives this

[opencl_init] opencl library ‘libOpenCL’ found on your system and loaded
[opencl_init] found 4 platforms
[opencl_init] no devices found for Advanced Micro Devices, Inc. (vendor) - AMD Accelerated Parallel Processing (name)
[opencl_init] found 3 devices

rocminfo

ROCk module is loaded

HSA System Attributes

Runtime Version: 1.1
System Timestamp Freq.: 1000.000000MHz
Sig. Max Wait Duration: 18446744073709551615 (0xFFFFFFFFFFFFFFFF) (timestamp count)
Machine Model: LARGE
System Endianness: LITTLE

==========
HSA Agents


Agent 1


Name: Intel(R) Core™ i7-8700K CPU @ 3.70GHz
Uuid: CPU-XX
Marketing Name: Intel(R) Core™ i7-8700K CPU @ 3.70GHz
Vendor Name: CPU
Feature: None specified
Profile: FULL_PROFILE
Float Round Mode: NEAR
Max Queue Number: 0(0x0)
Queue Min Size: 0(0x0)
Queue Max Size: 0(0x0)
Queue Type: MULTI
Node: 0
Device Type: CPU
Cache Info:
L1: 32768(0x8000) KB
Chip ID: 0(0x0)
Cacheline Size: 64(0x40)
Max Clock Freq. (MHz): 4700
BDFID: 0
Internal Node ID: 0
Compute Unit: 12
SIMDs per CU: 0
Shader Engines: 0
Shader Arrs. per Eng.: 0
WatchPts on Addr. Ranges:1
Features: None
Pool Info:
Pool 1
Segment: GLOBAL; FLAGS: FINE GRAINED
Size: 16216332(0xf7710c) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Alignment: 4KB
Accessible by all: TRUE
Pool 2
Segment: GLOBAL; FLAGS: KERNARG, FINE GRAINED
Size: 16216332(0xf7710c) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Alignment: 4KB
Accessible by all: TRUE
Pool 3
Segment: GLOBAL; FLAGS: COARSE GRAINED
Size: 16216332(0xf7710c) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Alignment: 4KB
Accessible by all: TRUE
ISA Info:


Agent 2


Name: gfx803
Uuid: GPU-XX
Marketing Name: Radeon RX 570 Series
Vendor Name: AMD
Feature: KERNEL_DISPATCH
Profile: BASE_PROFILE
Float Round Mode: NEAR
Max Queue Number: 128(0x80)
Queue Min Size: 64(0x40)
Queue Max Size: 131072(0x20000)
Queue Type: MULTI
Node: 1
Device Type: GPU
Cache Info:
L1: 16(0x10) KB
Chip ID: 26591(0x67df)
Cacheline Size: 64(0x40)
Max Clock Freq. (MHz): 1244
BDFID: 256
Internal Node ID: 1
Compute Unit: 32
SIMDs per CU: 4
Shader Engines: 4
Shader Arrs. per Eng.: 1
WatchPts on Addr. Ranges:4
Features: KERNEL_DISPATCH
Fast F16 Operation: TRUE
Wavefront Size: 64(0x40)
Workgroup Max Size: 1024(0x400)
Workgroup Max Size per Dimension:
x 1024(0x400)
y 1024(0x400)
z 1024(0x400)
Max Waves Per CU: 40(0x28)
Max Work-item Per CU: 2560(0xa00)
Grid Max Size: 4294967295(0xffffffff)
Grid Max Size per Dimension:
x 4294967295(0xffffffff)
y 4294967295(0xffffffff)
z 4294967295(0xffffffff)
Max fbarriers/Workgrp: 32
Pool Info:
Pool 1
Segment: GLOBAL; FLAGS: COARSE GRAINED
Size: 4194304(0x400000) KB
Allocatable: TRUE
Alloc Granule: 4KB
Alloc Alignment: 4KB
Accessible by all: FALSE
Pool 2
Segment: GROUP
Size: 64(0x40) KB
Allocatable: FALSE
Alloc Granule: 0KB
Alloc Alignment: 0KB
Accessible by all: FALSE
ISA Info:
ISA 1
Name: amdgcn-amd-amdhsa–gfx803
Machine Models: HSA_MACHINE_MODEL_LARGE
Profiles: HSA_PROFILE_BASE
Default Rounding Mode: NEAR
Default Rounding Mode: NEAR
Fast f16: TRUE
Workgroup Max Size: 1024(0x400)
Workgroup Max Size per Dimension:
x 1024(0x400)
y 1024(0x400)
z 1024(0x400)
Grid Max Size: 4294967295(0xffffffff)
Grid Max Size per Dimension:
x 4294967295(0xffffffff)
y 4294967295(0xffffffff)
z 4294967295(0xffffffff)
FBarrier Max Size: 32
*** Done ***

How to know if my RX-570 is supported?

According to

https://docs.amd.com/bundle/Hardware_and_Software_Reference_Guide/page/Hardware_and_Software_Support.html

GFX8 GPUs are “enabled in the ROCm software, though full support is not guaranteed”.

Some things to verify:

  • Is there AMD ocl in /etc/OpenCL/vendors/?
  • Does clinfo -l show your GPU

Both Yes

clinfo
Number of platforms                               1
  Platform Name                                   AMD Accelerated Parallel Processing
  Platform Vendor                                 Advanced Micro Devices, Inc.
  Platform Version                                OpenCL 2.1 AMD-APP (3558.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                                   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]              <error: no devices in non-default plaforms>
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  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)  No devices found in platform

No GPU device available.

Verify that you are a member of video and render groups.

I am member of both the groups

raj@:~$ members video
raj
raj@:~$ members render
raj

This usually only installs the required tools, but you still need to run those tools in order to install the desired driver setup.
In my case I set up OpenCL support with my AMD RX5700XT as follows:
sudo amdgpu-install --usecase=graphics,opencl --opencl=rocr
At least I’m abel to utilize OpenCL in darktable with this setup.

You installed it in the past with the proprietary opencl libraries, did you try that way(link below) ?

I’m telling you so because I had a RX580 and it worked great with mesa + amd proprietary opencl libraries.

I used
sudo amdgpu-install --usecase=graphics,opencl --no-dkms --no-32 --accept-eula
But that also didn’t work. I think the latest ROCm doesn’t support RX-570

@rgo Yes that worked for me on Ubuntu 22.04 but as DT is no longer updating for Ubuntu 22.04 and it will not be supported for the upcoming 4.4, The DT developer wants to give something cutting edge which not possible in Ubuntu 22.04 but still using OpenCL which the inventor Apple has already years ago deprecated! I upgraded to Ubuntu 23.04 and officially AMD has no official supported drivers for it. Specially OpenCL=legacy requires supported kernel and AMD DKMS, which will fail in Ubuntu 23.04.

As of now I am using DT with Intel NEO driver which are available in 23.04 (which by the way has no impact on speed). The rustcl mesa drivers though enables OpenCL but it is not used by DT as it has no image support!!!

So now I have no clue what to do. Someone suggested that I should switch to some other distro like Arch and it’s like getting myself adopted by a new family at this age!

Well, changing all that code that makes DT fast(i.e. OpenCL) is not that easy. You can try vkdt, that uses vulkan and a totally different paradigm (nodes graph).

It seems that rusticl is able to run darktable: Mesa's "Rusticl" Implementation Now Manages To Handle Darktable OpenCL - Phoronix

Thing is that Mesa 22.3 has it included but not enabled by default. You need to compile it yourself (read somewhere). It’s a pity :sweat:

You could try

sudo amdgpu-install --opencl=legacy --no-dkms

in case that still brings in support for RX570.

Which Intel GPU? For supported Intel GPUs all that is needed (for OpenCL) is:

apt install intel-opencl-icd

(it will pull all other necessary packages).

I am sure you know this for a fact but if not it seems like the latest code from the dev is still being built for 22.04 so are you 100% sure it is not going to run as 4.4 on 22.04 Ubuntu??

Opencl=legacy and no-dkms are mutually exclusive

I have already installed intel-opencl-icd

I think it will not be as master branch for ubuntu 22.04 has no updates after 4.3-1231 or similar for others it is some 2629 and being updated mostly once or twice a week.
By the way I have again shifted to macOS as DT is faster than what I am using on Ubuntu without rx-570 opencl and is the current build thanks to @MStraeten

This migth be the latest amdgpu-pro, which still supports RX570:
https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-22-40