Blender, AMD, and OpenCL

Hey all,

I recently joined this community last week and I experienced quite a faff in order to get my use case for this desktop to work. I did some searching on this Discourse and couldn’t find the info I needed, so I thought I would contribute it here in case anyone needed it in the future.

Here’s my use case:
I’m a Blender user who switched to Fedora. I recently acquired an AMD card which falls under the newer proprietary AMD driver capabilities (Radeon RX 6700 XT). I want to make use of Blender’s HIP GPU rendering under AMD which doesn’t work without their proprietary OpenCL magic.

Here’s what I had to do to make it work! I’m going to start out by saying I did not figure this process out on my own. I followed a guide here from reddit: https://www.reddit.com/r/Fedora/comments/v8r31k/how_i_got_blender_32_to_render_with_my_radeon_gpu/

Step 1: Add /etc/yum.repos.d/rocm.repo with these contents:

[ROCm]
name=ROCm
baseurl=http://repo.radeon.com/rocm/yum/rpm
enabled=1
gpgcheck=0

Step 2: Download the official AMDGPU driver installer for RHEL 9: https://repo.radeon.com/amdgpu-install/22.10.2/rhel/9.0/amdgpu-install-22.10.2.50102-1.el9.noarch.rpm

Then install it using sudo dnf install ./amdgpu-install-22.10.2.50102-1.el9.noarch.rpm

Step 3: Navigate to: Index of /amdgpu/22.10.3/rhel/8.6/main/x86_64/

And download these files:
amdgpu-core-22.10.3.50103-1420322.el8.noarch.rpm
libdrm-amdgpu-common-1.0.0.50103-1420322.el8.noarch.rpm
libdrm-amdgpu-2.4.109.50103-1420322.el8.x86_64.rpm

Step 4: Install the above packages from their location (Downloads folder) using this command (all at once):

sudo dnf install amdgpu-core-22.10.3.50103-1420322.el8.noarch.rpm libdrm-amdgpu-common-1.0.0.50103-1420322.el8.noarch.rpm libdrm-amdgpu-2.4.109.50103-1420322.el8.x86_64.rpm

Now, DNF told me that amdgpu-core failed to install, and that the Transaction failed, but the other two packages installed successfully which is what’s important!

Step 5: Install the rest of the components with the installer installed previously from the (also already added) ROCm repo:

amdgpu-install --usecase=opencl,hip --no-dkms

Now open up Blender 3.2 and check the system settings; you should see the HIP tab and your GPU there!

1 Like

How do you feel about writing a howto? Or doing a Fed Mag article?

I feel like an imopster! But this is useful info, so I’m for it :smiley:

2 Likes

@glb and @rlengland ,
Could you guys use an article about this?

Is this about the Blender removal of OpenCL support on AMD GPUs and the effort to make Blender usable on those graphics cards? It may be a bit specific but there are probably enough Blender users in the Fedora Linux realm to make it worth while.

That’s my 2 cents worth.

(I should read the entire thread, eh? :slight_smile: )

2 Likes

I think I concur with the statement that the author made in the last paragraph:

Obviously I don’t encourage anyone to do what I did …

While I’m sure it is a useful hack for many people to work around the current problem, I don’t think Fedora Magazine should promote this.

Just my 2¢

1 Like

@rlengland I agree that this may be a pretty specific use case. With Nvidia cards, there’s so much that ‘just works’ for Blender users who run Fedora, but in order for AMD users to be able to get GPU compute capability out of their cards, more steps are necessary. This was something I really needed when I switched.

@glb That warning rings true. It is a hack, and someone else’s mileage may vary. In fact, it’s entirely possible that this hack will only work until AMD produces a newer proprietary driver (if there are changes to the OpenCL portion) or if Blender makes a breaking change to their HIP implementation.

My intention was only to point other Blender/Fedora AMD users toward something that helped me get GPU compute capabilities out of the Cycles render engine under Blender 3.2. The reddit article was difficult for me to find, so I thought drawing some attention to it may help others find it, too!

Yes, AMD is unfortunately being problematic, and Nvidia is not always able to “just work”, although the included drivers are pretty good.
Perhaps a howto doc https://docs.fedoraproject.org/en-US/quick-docs/contribute-to-quick-docs/ would be more appropriate.

1 Like

Hi,

First off Thank you for creating this post!

After following the steps I unfortunately still had a few issues:

  1. No devices would show up in the HIP Tab in the Blender System Settings.
    When I checked the console where I opened blender I saw an error something like “which: hipcc not found”. (I don’t have the exact error anymore unfortunately)
    To get hipcc I had to install the package hip-devel

  2. Even after installing that package I didn’t have /opt/rocm/bin (where hipcc is located) in my $PATH, so I created the following file:
    echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin/x86_64' | sudo tee -a /etc/profile.d/rocm.sh
    (I found this command in the ROCm Docs)
    Only then my GPU and CPU (5900XT & 5800X) showed up in the HIP Panel in blender.

  3. After turning on both devices in the Blender HIP System Settings I tried rendering in Cycles using the GPU but got the following error in the console (and the render just didn’t start):

[...] 
Compiling HIP kernel ...
hipcc -Wno-parentheses-equality -Wno-unused-value --hipcc-func-supp -O3 -ffast-math --amdgpu-target=gfx1030 -I /usr/share/blender/3.2/scripts/addons/cycles/source --genco /usr/share/blender/3.2/scripts/addons/cycles/source/kernel/device/hip/kernel.cpp -o "/home/joni/.cache/cycles/kernels/cycles_kernel_gfx1030_D473C7AC23F611898D03A1AA639945AA"
clang-14: error: cannot find ROCm device library; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library
Failed to execute compilation command, see console for details.
[...] 

So I tinkered and researched for a bit and tried installing the package “rocm-device-libs” which provides /usr/lib64/amdgcn/bitcode which apparently is needed?!
I also had to set DEVICE_LIB_PATH=/usr/lib64/amdgcn/bitcode because hipcc just wouldn’t find it.
So I expanded the file which I created earlier by a second line:

[joni@linuxjoni02 bin]$ cat /etc/profile.d/rocm.sh
#FOR BLENDER
export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin/x86_64
export DEVICE_LIB_PATH=/usr/lib64/amdgcn/bitcode

And now It seems to work - I could at least render the default cube a couple of times.

Did I miss something or does somebody know, why I had to do these extra steps?

You’re so welcome!

I’m sorry to hear that you encountered some bumps along the way. It sounds like you did a lot of extra research and work to make this possible on your machine. I’m not certian why you needed to do so much more faffing than I did in order to get Blender to recognize your AMD GPU/CPU.

How do you download Blender? For instance, I always download the AppImage directly from Blender.org. Do you use the Fedora repositories? Flatpak?

All the HIP packages I needed were in those libraries I downloaded, as well as the amdgpu-install package for hip in step 5.

I have found, though, that the way that I installed things above has caused great instability in my X and Wayland experience when using the Blender viewport with my AMD GPU (I also have an NVIDIA GPU that I use in tandem to use viewport now). I think it’s related to this issue: Random freezes on fedora 36 with AMD GPU - #6 by computersavvy - Ask Fedora also discussed tangentially here: Where to report AMD GPU lockups crasher/hangs bugs related to seemingly triggered by Firefox / VA-API after resuming from suspend? - Ask Fedora.

I think there’s an open bug for it, (2022980 – [abrt] radeon_bo_unref: WARNING: CPU: 4 PID: 1408 at drivers/gpu/drm/radeon/radeon_object.c:83 radeon_ttm_bo_destroy+0xde/0xf0 [radeon] [radeon]) but almost every time I try to navigate through the viewport using my RX 6700 XT, my entire X session (or Wayland) crashes and I have to pkill my user to log back in. It’s a very frustrating issue, but HIP works consistently for rendering (again, just not viewport in Blender).

I would love to hear about the stability of Blender viewport using the method you described here, and how you’re using Blender (AppImage, flatpak, rpm) to compare!

Hi!
I prefer “standard” packages instead of flatpak or AppImage so I got the latest available blender Version (3.2.1) on the fedora package testing page
https://bodhi.fedoraproject.org/updates/FEDORA-2022-7fe04fc1a5

I didn’t have any issues so far, but I only worked with it for ~3h yesterday creating some textures in the node editor.
I wasn’t using the viewport much, but I was moving around/rotating a bit to get a good view in the “rendered” view checking reflections for example and had no issues - it was smooth, fast and stable.

I am running on Wayland (and KDE) - I don’t use X11 anymore, so I can’t say anything about that.

I attached a Screenshot of my Setup (I can only embed one picture unfortunately):

In Blender System Settings I have both the CPU and GPU enabled and can render without issues.

some additional Info about my system:

[joni@linuxjoni02 ~]$ blender --version | head -5
Blender 3.2.1
        build date: 2022-07-11
        build time: 00:00:00
        build commit date: 1970-01-01
        build commit time: 00:00
[joni@linuxjoni02 ~]$ neofetch
             .',;::::;,'.                joni@linuxjoni02                                                                                                                                           
         .';:cccccccccccc:;,.            ----------------                                                                                                                                           
      .;cccccccccccccccccccccc;.         OS: Fedora Linux 36 (KDE Plasma) x86_64                                                                                                                    
    .:cccccccccccccccccccccccccc:.       Kernel: 5.18.16-200.fc36.x86_64                                                                                                                            
  .;ccccccccccccc;.:dddl:.;ccccccc;.     Uptime: 9 mins                                                                                                                                             
 .:ccccccccccccc;OWMKOOXMWd;ccccccc:.    Packages: 2742 (rpm)                                                                                                                                       
.:ccccccccccccc;KMMc;cc;xMMc:ccccccc:.   Shell: bash 5.1.16                                                                                                                                         
,cccccccccccccc;MMM.;cc;;WW::cccccccc,   Resolution: 2560x1440                                                                                                                                      
:cccccccccccccc;MMM.;cccccccccccccccc:   DE: Plasma 5.25.4                                                                                                                                          
:ccccccc;oxOOOo;MMM0OOk.;cccccccccccc:   WM: kwin                                                                                                                                                   
cccccc:0MMKxdd:;MMMkddc.;cccccccccccc;   WM Theme: GruvboxAurorae                                                                                                                                   
ccccc:XM0';cccc;MMM.;cccccccccccccccc'   Theme: [Plasma], Adwaita [GTK2], Breeze [GTK3]                                                                                                             
ccccc;MMo;ccccc;MMW.;ccccccccccccccc;    Icons: [Plasma], candy-icons [GTK2/3]                                                                                                                      
ccccc;0MNc.ccc.xMMd:ccccccccccccccc;     Terminal: cool-retro-term                                                                                                                                  
cccccc;dNMWXXXWM0::cccccccccccccc:,      CPU: AMD Ryzen 7 5800X (16) @ 3.800GHz                                                                                                                     
cccccccc;.:odl:.;cccccccccccccc:,.       GPU: AMD ATI Radeon RX 6800/6800 XT / 6900 XT                                                                                                              
:cccccccccccccccccccccccccccc:'.         Memory: 3284MiB / 31999MiB                                                                                                                                 
.:cccccccccccccccccccccc:;,..                                                                                                                                                                       
  '::cccccccccccccc::;,.                                                                                                                                                                                                                                                                                                                                                                
1 Like

I have to say a huge THANK YOU for explaining your process. I followed your steps:

  1. Install blender, hip-devel, and rocm-device-libs
  2. echo 'export PATH=$PATH:/opt/rocm/bin:/opt/rocm/profiler/bin:/opt/rocm/opencl/bin/x86_64 export DEVICE_LIB_PATH=/usr/lib64/amdgcn/bitcode' | sudo tee -a /etc/profile.d/rocm.sh
  3. Restart the machine
  4. Login under Wayland OR X

After I followed those steps, now I can use my RX 6700 XT with Blender and navigate around the viewport without having terrible crashes that result in lost work and having to kill the user session to log back in.

Thank you, and thank you again.

EDIT: I’m still seeing some instability, but it seems to be localized to certain textures. I could be wrong, but I think my machine is still having trouble with the setup :frowning:

Glad to hear that it somewhat helped. I hope you get the rest sorted out as well.
By the way: If you have the .blend file I can try to reproduce your issue, if that helps.

Uh oh!
I think I got the same issue as you with my entire system (most likely the amd driver) crashing because of the blender viewport (but as far as I see it only happens in the rendered viewport).

when checking the last lines of the journalctl command I see some different amdgpu crashes.

Aug 11 21:35:40 linuxjoni02 kernel: [drm:amdgpu_dm_atomic_commit_tail [amdgpu]] *ERROR* Waiting for fences timed out!
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_dm_atomic_commit_tail [amdgpu]] *ERROR* Waiting for fences timed out!
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring gfx_0.0.0 timeout, signaled seq=64866, emitted seq=64868
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_job_timedout [amdgpu]] *ERROR* Process information: process blender pid 2370 thread blender:cs0 pid 2392
Aug 11 21:35:45 linuxjoni02 kernel: amdgpu 0000:0c:00.0: amdgpu: GPU reset begin!
Aug 11 21:35:45 linuxjoni02 kernel: amdgpu: Failed to suspend process 0x800a
Aug 11 21:35:45 linuxjoni02 kernel: amdgpu_cs_ioctl: 134 callbacks suppressed
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:45 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:46 linuxjoni02 kernel: amdgpu 0000:0c:00.0: [drm:amdgpu_ring_test_helper [amdgpu]] *ERROR* ring kiq_2.1.0 test failed (-110)
Aug 11 21:35:46 linuxjoni02 kernel: [drm:gfx_v10_0_hw_fini [amdgpu]] *ERROR* KGQ disable failed
Aug 11 21:35:46 linuxjoni02 kernel: amdgpu 0000:0c:00.0: [drm:amdgpu_ring_test_helper [amdgpu]] *ERROR* ring kiq_2.1.0 test failed (-110)
Aug 11 21:35:46 linuxjoni02 kernel: [drm:gfx_v10_0_hw_fini [amdgpu]] *ERROR* KCQ disable failed
Aug 11 21:35:46 linuxjoni02 kernel: [drm:gfx_v10_0_hw_fini [amdgpu]] *ERROR* failed to halt cp gfx

And further below

Aug 11 21:35:47 linuxjoni02 kernel: [drm] Skip scheduling IBs!
Aug 11 21:35:47 linuxjoni02 kernel: [drm] Skip scheduling IBs!
Aug 11 21:35:47 linuxjoni02 kernel: [drm] Skip scheduling IBs!
Aug 11 21:35:47 linuxjoni02 kernel: [drm] Skip scheduling IBs!
Aug 11 21:35:47 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:47 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:47 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:47 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:48 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: amdgpu_cs_ioctl: 18 callbacks suppressed
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:35:57 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:36:07 linuxjoni02 kernel: amdgpu_cs_ioctl: 10 callbacks suppressed
Aug 11 21:36:07 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!
Aug 11 21:36:07 linuxjoni02 kernel: [drm:amdgpu_cs_ioctl [amdgpu]] *ERROR* Failed to initialize parser -125!

Just not using the rendered view and then rendering stuff normally seems to still work fine at the moment.

I think I’ll open a bug report on blender just to be sure, because it doesn’t really sound the same as ⚓ T97591 Cycles HIP error with image textures on Linux and RDNA1

1 Like

Ahh yes. So the ‘fix’ I thought I had has been a fine line and I’m still getting this exact same crash. When you have that bug up, would you mind linking it so that I can throw a +1 on there, too? It’s been making me crazy enough to want to try other Linux distros just to see if someone out there has a magical answer to this dilemma. :frowning:

Here’s the link to my Blender bug report - feel free to add your experience to the “Task”

https://developer.blender.org/T100353