ninethehacker.xyz Enabling Hardware Render for Linux/Blender on AMD Hardware

Enabling Hardware Render for Linux/Blender on AMD Hardware

the misery of compute on AMD


Completing the build on my PC was a lot of fun, unfortunately I’ve discovered that the reports of AMD support being superior were quite exagerated, the kernel driver is graphics oriented rather than scientific, and things like OpenCL working out of the box appear to have had more to do with the work intel had put in than the state of the art.

I had heard that Pop_Os! had put extensive effort into being a development platform out of the box, this has not proved to be the case trying to get hardware accelerated OpenCL working on AMD.

So far the most success I’ve had (AMD pro and ROCM drivers just broke on install and shredded my apt) was to install the open source Mesa OpenCL library with apt install clinfo mesa-opencl-icd however blender (deb version) didn’t recognise my card, clinfo | grep OpenCL returned:

Platform Version                                OpenCL 1.1 Mesa 20.0.4
Device Version                                  OpenCL 1.1 Mesa 20.0.4
Device OpenCL C Version                         OpenCL C 1.1 
Run OpenCL kernels                            Yes
ICD loader Name                                 OpenCL ICD Loader
ICD loader Profile                              OpenCL 2.1

So I have OpenCL and it can find my RX580. But I think the blender renderer wants OpenCL 1.2, I’m going to try to add the blender pro-render plugin to see if that will help.

Ok, I set up pro-render with the following steps:

Unfortunately it depends on blender’s openCL loader which meant it still rendered on the CPU, and because it enables more features by default it’s considerably slower than cycles for my test scene.

Disheartened I took another swing at installing the amd pro drivers. The minimal packages for openCL are:

  • amdgpu-core*.deb
  • amdgpu-pro-core*.deb
  • opencl-amdgpu-pro-comgr*.deb
  • opencl-amdgpu-pro-icd*.deb

After installing these packages clinfo reports OpenCL 2.1 support. However blender is not recognising my graphics card, this persists whether or not I remove Mesa’s OpenCL core from my system.

Users have stated that the ROCM OpenCL driver for xenial works in stock ubuntu 20.04. I’m considering moving to that because compute is non-negotiable. Research has also indicated that Arch/Manjaro have a package called amd-opencl which streamlines the process of installing OpenCL.

update

You can install the OpenCL portion of the AMD Adrenalin driver with the following packages:

  • libdrm2-amdgpu_2.4.100*.deb
  • libdrm-amdgpu-common_1.0.0*.deb
  • libdrm-amdgpu-amdgpu1_2*.deb
  • libdrm2-amdgpu*.deb
  • libopencl1-amdgpu-pro*.deb

I have not verified that these are the only packages required, see above for the complete list of packages I cribbed from the Adrenalin driver.

clinfo was no longer able to find the later version of openCL, however, for technical and political reasons nearly all software is developed against OpenCL 1.2 and not the 2.x revision. This alllowed blender to find my graphics card, this left me with the worrying realisation that the OpenCL renderer was single threaded and would only render a single tile on my machine at a time, making it significantly slower than CPU rendering in my test blend update: after some software updates and a reboot I can now force mulithreading by changing threads from auto to fixed and cranking the number of threads up. This seems to max out at 16 for my rx580.

I had already installed AMD pro-render, which, while slower than cycles for basic scenes, can render entire frames in one pass and includes a more complex shading model for transparent and refractive materials. In order to preview materials or perform viewport rendering I had to go to Render Tab > Sampling > Viewport & Preview Sampling and uncheck OpenGL Interoperability.

It’s interesting and somewhat concerning that AMD chose to write an entire rendering engine rather than add a Vulkan backend to cycles or improve the OpenCL backend, I’ve heard they don’t exactly understand the open source ecosystem and the integration model, I hope they’ll maintain pro-render longer than it takes for Mesa’s OpenCL implementation to gain 1.2 conformance and for cycles to gain Vulkan acceleration.

stay tuned

I still need to enable acceleration for tensorflow and this might prove to be very tricky. I believe I will need to dig back into ROCM, check here for more.


there are no comments yet


all comments are manually reviewed before publication