Page 2 of 2

Re: GPU rendering on linux

Posted: Tue Mar 12, 2019 11:07 am
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.

Re: GPU rendering on linux

Posted: Tue Mar 12, 2019 11:34 am
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...

Re: GPU rendering on linux

Posted: Tue Mar 12, 2019 12:09 pm
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.

Re: GPU rendering on linux

Posted: Tue Mar 12, 2019 12:19 pm
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?

Re: GPU rendering on linux

Posted: Tue Mar 12, 2019 12:42 pm
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)

Re: GPU rendering on linux

Posted: Thu Sep 17, 2020 4:57 pm
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?

Re: GPU rendering on linux

Posted: Thu Sep 17, 2020 7:07 pm
by timurhai
Hi!
If you are using Linux packages - you can tune SystemD service settings.
There are lots of manuals for this.

Re: GPU rendering on linux

Posted: Mon Jul 26, 2021 4:41 pm
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