GPU rendering on linux

User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: GPU rendering on linux

Post by timurhai »

So you should checkout difference between computers that use GPU and that use CPU.
But it seems that Blender needs a GUI session to use GPU (very pity).
May be all your ms windows afrenders runs within a GUI session?
And some Linuxes runs afrenders from init.d or systemd daemon with no GUI?
If so, you should write to Blender developers, other soft that uses GPU do not need a GUI session.
- what we should do with a cloud rendering? cloud with a GUI session is much more complex.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
mateusz@autonomy.pl
Posts: 16
Joined: Fri Jan 11, 2019 2:43 pm

Re: GPU rendering on linux

Post by mateusz@autonomy.pl »

Sory for my quite poor english.

It looks like its not blender itself.

This is rendering on CGRU. (look at cpu and gpu utilisation)
Image
And this is same command copied to terminal- so rendering without gui. Also i heard that blender works on AWS cloud withoud problem.
Image

This is all done on one computer. So it seems that its cgru issue not blender itself...
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: GPU rendering on linux

Post by timurhai »

"And this is same command copied to terminal- so rendering without gui"
- Terminal launched from GUI have a GUI. I see you screenshot - that terminal with a GUI.
In that terminal type:

Code: Select all

cd /opt/cgru
source ./setup.sh
afrender
- So that afrender client will be with GUI.
And check how it works.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
mateusz@autonomy.pl
Posts: 16
Joined: Fri Jan 11, 2019 2:43 pm

Re: GPU rendering on linux

Post by mateusz@autonomy.pl »

jesus... it works that way.
Thank you very much
I'll make this as my workaround then....
What should i exacly write to blender devs to make them aware of issue?
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: GPU rendering on linux

Post by timurhai »

At first you should ask:
- Can I render using GPU running Blender command line with no display? If I can, how to do it?
(may be we are doing something wrong)
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
jpn1994
Posts: 2
Joined: Tue May 29, 2018 9:59 am
Location: Porto, Portugal

Re: GPU rendering on linux

Post by jpn1994 »

Found this thread when looking for why is afrender not able to use GPU. I belive this has something to do to the lack of permissions of the "render" user that is used by the afrender service. It works when you run it with the way that timurhai posted as it is using the user you are currently logged in with. Can you change the user that the afrender service runs with?
User avatar
timurhai
Site Admin
Posts: 911
Joined: Sun Jan 15, 2017 8:40 pm
Location: Russia, Korolev
Contact:

Re: GPU rendering on linux

Post by timurhai »

Hi!
If you are using Linux packages - you can tune SystemD service settings.
There are lots of manuals for this.
Timur Hairulin
CGRU 3.3.1, Ubuntu 20.04, 22.04, MS Windows 10 (clients only).
Plyro
Posts: 1
Joined: Mon Jul 26, 2021 4:19 pm

Re: GPU rendering on linux

Post by Plyro »

For anyone else still dealing with this problem:

Automatic GPU detection was deactivated in headless mode, since it could lead to crashes on startup.
See:
https://devtalk.blender.org/t/headless- ... us/12176/3

The solution is to run GPU detection after loading your file; specifically

Code: Select all

bpy.context.preferences.addons['cycles'].preferences.get_devices()
This can be done via a small add-on or with a registered script from within the .blend file (this could even be linked in from a central file; depending on your pipeline).
This snippet worked perfectly for me (taken from https://blender.stackexchange.com/a/154512 and edited):

Code: Select all

import bpy

def activate_cuda_devices(context, cpu=True, gpu=True):
    """
    Update CUDA devices and activate them based on parameters
    """
    cycles_preferences = context.preferences.addons['cycles'].preferences
    cuda_devices, opencl_devices = cycles_preferences.get_devices()

    cycles_preferences.compute_device_type = 'CUDA'

    for device in cuda_devices:
        if (cpu and device.type == 'CPU') or (gpu and device.type == 'CUDA'):
            print(f'Activating {device.name}')
            device.use = True
        else:
            print(f'Deactivating {device.name}')
            device.use = False

activate_cuda_devices(bpy.context, cpu=True, gpu=True)
Hope that helps!
All the best,
-Tristan
Post Reply