OpenCL (GPGPU) on AMD (ATI) GPUs
Using GPU for computing can give you great speedup – 3x, 10x, 100x, or even more. We can describe modern GPU as a set of many (100 – 10000) rather simple CPUs, connected to very fast dedicated RAM. To use this power you need drivers, which support some compute standards – OpenCL, CUDA, Vulkan, or something else. AMD supports OpenCL, CUDA via HIP translator, Vulkan, and other standards.
You don’t need OpenCL for desktop acceleration, web browsers and other ordinary tasks, you need only 3D drivers for that: OpenGL, sometimes Vulkan. For hardware acceleration Firefox Webrender requires OpenGL 3.0, KDE requires OpenGL 3.1.
Check hardware specifications with AMD GPU list here.
You can get some acceleration in some applications with your GPU(s) after installing needed drivers. For instance, you can use GPU acceleration in Darktable and Blender after changing appropriate settings. Also you can use GPU to accelerate Ark or Dolphin after installing middleware drivers (see chapter "Using GPU for ordinary applications (GPGPU)" for details). For some applications you need additional tuning, read chapter Special Cases for details.
Volume of available video RAM is critical: often 1-2 GiB is a bare minimum, for complex tasks you may need 6 GiB or more. You can adjust available video RAM for builtin graphics via BIOS settings.
With OpenCL you can easily get 100% GPU load, so your desktop windows can stutter, web browser may hang. To avoid this behaviour dedicate one GPU (the simplest one, such as builtin) for desktop usage, and use other(s) for OpenCL acceleration. Also this solution will free some video RAM in accelerator for calculations.
Check supported OpenCL extensions with clinfo utility (clinfo package), measure speed with clpeak utility (clpeak package).
ATI FireGL – for Terascale 2 & 3 chips
OpenCL 1.2 support, incompatible with modern distributions.
Mesa 3D Clover - for different hardware
OpenCL 1.2 support without image support, often hangs. Mesa 3D will deprecate it in favor of Rusticl driver.
Mesa 3D Rusticl - for different hardware.
Introduced with Mesa 22.3. Under development. May not work right now with your hardware.
Certified OpenCL 3.0 support with image support, OpenCL 2.x - under development.
AMD ORCA – for AMD GCN 1 – GCN 4.
OpenCL 1.2 support.
AMD PAL – for AMD GCN 2 – GCN 5 and RDNA 1.
PAL = Platform Abstraction Library. The latest AMD driver package with PAL OpenCL inside is 20.40. Link to package is here. Newer drivers have ROCm-based OpenCL drivers for GCN5 and newer chips, and ORCA drivers for GCN4 and older ones. Works with Leap 15.2 & 15.3 (kernel 5.3.x), may work with newer kernels.
OpenCL 2.x support.
AMD ROCm drivers for OpenCL – for AMD GCN 5 and RDNA 1–3.
OpenCL 2.x support.
You may install it with downgrading X and other core packages. Instead of that use old & compatible distribution. You can use virtual machine for that.
Mesa 3D Clover
It hangs too much. Simply do not use it.
Mesa 3D Rusticl
Use the latest available Mesa 3D drivers.
For openSUSE Leap 15.3/15.4 add Mesa 3D experimental repository. Perform vendor change upgrade using this Mesa 3D repo. Then install Rusticl packages from it.
For Tumbleweed simply install Rusticl packages.
Install AMD proprietary drivers – all packages or OpenCL only (‘headless’ option).
With installing headless AMD drivers you will use Mesa 3D drivers for 3D and AMD OpenCL drivers for OpenCL.
Supposedly you need amdgpu kernel driver to use AMD OpenCL drivers. For GCN 1 & 2 amdgpu driver is still in experimental phase, so you need kernel parameters to use amdgpu instead of radeon one. Add to kernel parameters “radeon.si_support=0 amdgpu.si_support=1” for GCN1, and “radeon.cik_support=0 amdgpu.cik_support=1” for GCN2. See here for details.
With GCN 1 & 2 and amdgpu driver VGA output in video card may not work. For GCN 2 – 4 with AMD PAL drivers you will get OpenCL 2.0 instead of OpenCL 1.2.
Use this instruction. With installing headless AMD drivers you will use Mesa 3D drivers for 3D and AMD OpenCL drivers for OpenCL.
AMD creates ROCm mainly for supercomputer market, for CDNA product line and its predecessor GCN5 (a.k.a. Vega graphics). Only some consumer products with RDNA architectures support ROCm by default, and only discrete video cards. However, GCN 4 may work, possibly after recompiling of ROCm with changed parameters, older generations need tests & additional work. OpenCL with APUs also may work.
Reference Guide about supported hardware is here, it is usually outdated and has mistakes.
For AMD ROCm drivers with pre-Vega (i.e. GCN 4 and older ones) GPUs you need support for PCIe atomics feature (PCIe 3.0 and newer). Some old CPUs and motherboards do not support PCIe atomics. AMD Ryzen family (including Athlon 200GE/300GE/3000G and newer) supports PCIe atomics. AMD AM3+ and older sockets lacks PCIe atomics.
To check compatibility use command (with GPU being installed)
sudo dmesg | grep -i kfd
If you find something like
kfd kfd: added device 1002:15d8
, then your system supports PCIe atomics. Without PCIe atomics you will get something like
kfd: skipped device 1002:7300, PCI rejects atomics
Install AMD proprietary drivers or add one of ROCm repository and install needed packages from it. Some ROCm (https://repo.radeon.com/rocm/zyp/) repos (use one of them):
Sometimes you need full re-installation of ROCm packages, not just simple upgrade.
Running on unsupported hardware
This tricks ROCm into treating your card as a Navi 21 card (link). It is better to use GFX number from the same generation. For GCN use GCN substitutes, not RDNA ones.
Using GPU for ordinary applications (GPGPU)
You can use OpenCL acceleration with Ark for (de)compressing files for some formats or with Dolphin for calculating checksums after installing appropriate middleware drivers. For AMD OpenCL drivers install libdrm-amdgpu package from AMD proprietary drivers or from AMD repos, and uninstall & taboo libdrm_amdgpu1 package from Mesa 3D to avoid hangs. Right now libdrm_amdgpu1 package from Mesa 3D doesn't support GPGPU, may get it in some future with Rusticl drivers.
Sources of amdgpu driver
AMD repository for amdgpu, Mesa 3D stuff and etc. is here. Choose appropriate subfolder.
For Leap you can use amdgpu driver from AMD packages or from distribution (xf86-video-amdgpu package). To use amdgpu driver from AMD packages you need working DKMS. AMD tests ROCm with amdgpu driver from AMD packages. Amdgpu driver from distribution works OK and is easily maintained for end user. It is better to use one source of amdgpu driver, otherwise system will hop from one to another.
With Tumbleweed you have to use amdgpu driver from distribution.
OpenCL on openSUSE Tumbleweed
While AMD supports OpenCL on SUSE SLE (= openSUSE Leap) only, you can use AMD OpenCL drivers with Tumbleweed by manually choosing which packages to install. Or you can compile drivers by yourself.
Of course, you can use Mesa 3D OpenCL drivers with Tumbleweed.
Download archive from blender.org, extract, and use it as a portable install. Blender 2.x works OK with OpenCL. Blender 3.x doesn't support OpenCL, emits CUDA commands, requires working AMD HIP translator from AMD ROCm. For GCN5 use HIP 5.3 and newer. Older GPUs are not supported right now.
DaVinci Resolve requires unconventional OpenCL extensions cl_khr_gl_sharing and cl_khr_image2d_from_buffer, which may not be available in some drivers (AMD ORCA, Mesa 3D Rusticl). Read here for details: link1, link2, link3. Also you may need to install Workstation (Proprietary) (previously AMDGPU-Pro) OpenGL drivers.
- You can install and use more than one OpenCL driver. Configure installed drivers with icd files.
- Old AMD drivers contents installer and all packages in it. Script creates subfolder in system folder containing all packages and then installs packages from it. New AMD drivers installer uses AMD repositories at https://repo.radeon.com.
- You need special tuning to use amdgpu and radeon drivers simultaneously when system has GCN 1 or GCN 2 GPUs.
- Terascale chips lacks some commands for addressing memory, so you need some tuning to use OpenCL in Darktable via settings in file. Blender doesn’t support Terascale chips at all, needs GCN 1 and newer just to run (however, may work with software emulation).
- OpenCL on Terascale 1 and older AMD/ATI chips are not supported (well, it is possible, but meaningless).
- AMD officially supports OpenCL only with discrete video cards. However, OpenCL with APU works.
- You can use CPU(s) as OpenCL device after installing PoCL package or with LLVMpipe + Rusticl.
- You can run calculations in GPU and in CPU together.