Radeon Open Compute
3.7 / August 18, 2020
Radeon Open Compute (ROCm) is a open source development platform for GPU computing that consists of a variety of frameworks, programming models and tools. The most interesting and practically usable part of ROCm for most home users is the OpenCL support. Mesas Clover implementation is limited to OpenCL 1.2, installing ROCm is a requirement to use anything that requires OpenCL 2.0
ROCm is a complete GPU compute suite with support for a lot more than OpenCL. You can install all parts of it use it for things like OpenMP or just install the few packages you need to get OpenCL 2.0 working.
You need a fairly new AMD graphics card or the right graphics card to use ROCm. Some cards within the same older generations are supported while others are not. Newer generation (Vega/Nav) GPUs are supported but APUs are not.
You will need a CPU and motherboard combination with support for PCIe 3.0 with PCIe atomics. You have this if you have a moderately recent computer. You can use any machine with a AMD Ryzen CPU or APU or a Intel i3, i5, i7 or i9 that is Haswell or newer. You can also use AMD Threadripper and EPYC CPUs and newer Intel Xeons. The GPU should be in a slot that is connected to the processors root I/O controller (not the bottom x16 slot on consumer motherboards that is in reality a x4 PCIe slot going through the motherboards chipset). You can check how PCIe devices are connected by running
|GPU Family||Generation||ROCm status|
|CAPE VERDE, PITCAIRN, TAHITI, OLAND, HAINAN||gfx6|
|BONAIRE, KABINI, MULLINS, KAVERI, HAWAII||gfx7|
|TONGA, ICELAND/TOPAZ, CARRIZO, STONEY, VEGAM||gfx8|
|FIJI, POLARIS10, POLARIS11, POLARIS12||gfx8|
|VEGA10, VEGA12, VEGA20||gfx9|
You will ideally want Linux kernel 5.6 or newer. The amdkfd driver in kernels prior to 5.6 limits the GPUs system memory use to 3/8ths of total memory. 5.6+ allows the GPU to use up to 15/16ths.
ROCm supports a rather limited number of GNU/Linux distributions. AMD officially only supports:
- Ubuntu 20.04 and 18.04.4
- CentOS 7.8 & RHEL 7.8
- CentOS 8.2 & RHEL 8.2
- SLES 15 SP1
This is unfortunate because compiling ROCm is a problem (to put it mildly). You can, luckily, get the packages to work on non-supported distributions.
You must use the
amdgpu kernel module for your AMD GPU/APU (
radeon will not work) and your kernel must be compiled with
m ("HSA kernel driver for AMD GPU devices").
The ROCm GitHub Page has instructions for the "supported" distributions. You should install the
rock-dkms package if you are installing on a system with a Linux kernel <=5.4. Do not install it if you are using a newer kernel.
Fedora 32, OpenCL only
|Note: Following these simple steps will give you OpenCL 2.2 support so you can use OpenCL 2.x applications. You will need additional packages such as AOMP (A custom LLVM build) to use things like OpenMP.|
First, add the "yum" ROCm repository meant for RHEL:
echo '[ROCm] name=ROCm baseurl=http://repo.radeon.com/rocm/yum/3.7/ enabled=1 gpgcheck=1' > /etc/yum.repos.d/rocm.repo
Next, add the GnuPG key used to sign the packages in that repository (or switch to
rocm.repo if you want to live dangerously):
rpmkeys --import http://repo.radeon.com/rocm/rocm.gpg.key
You can, and probably should, eradicate all other OpenCL implementations from your system before you proceed to installing ROCm:
dnf -y remove hsakmt pocl beignet mesa-libOpenCL
You can now proceed with installing the actual ROCm packages you need:
dnf -y install hsakmt-roct npth-devel hsa-ext-rocr-dev rocm-utils rocm-opencl rocm-opencl-devel hip-base
ROCm (3.7.0, anyway) is installed to
/opt/rocm-3.7.0/ and the OpenCL library required by the OpenCL
.icd file it installs is placed in
/opt/rocm-3.7.0/opencl/lib/libamdocl64.so. That is not in the regular library path so it will not be found when you run
clinfo or other applications trying to use OpenCL. This is actually a minor problem that can be fixed with a simple
echo /opt/rocm-3.7.0/opencl/lib/libamdocl64.so > /etc/OpenCL/vendors/amdocl64_30700.icd
That's it. Running
clinfo (provided by a system package called
clinfo, you likely have it) should now show
Platform Name: AMD Accelerated Parallel Processing and a whole lot of incriminating information about your graphics card.
Testing If ROCm Is Working
The very simple program
clpeak, available as a package with that name, can be used to test if it is actually working.
clpeak is a OpenCL benchmarking program. It will test Global memory bandwidth (GBPS), Single-precision compute (GFLOPS), half-precision compute (GFLOPS), Double-precision compute (GFLOPS) and Integer compute (GIOPS) and print a list such as
Platform: AMD Accelerated Parallel Processing Device: gfx803 Driver version : 3182.0 (HSA1.1,LC) (Linux x64) Compute units : 32 Clock frequency : 1268 MHz Global memory bandwidth (GBPS) float : 143.32 float2 : 145.39 float4 : 151.33 float8 : 152.71 float16 : 129.04 Single-precision compute (GFLOPS) float : 4910.25 float2 : 4352.29 float4 : 4490.20 float8 : 3740.20 float16 : 3353.13 (..and more)