0
$\begingroup$

Alright, so i have a slightly strange system configuration. I'm running Zorin OS 12, which is roughly equivalent to Ubuntu 16.04. I am also running Mesa, but i use AMD's OpenCL. It works just fine with various miners i tested.

Now i want blender to actually render on the GPU. Blender detects it when i use the split kernel, but for some reason, whatever i do, it always falls back to the cpu.

Here's the script i use:

import bpy, _cycles
bpy.ops.wm.open_mainfile(filepath="/home/xxx/xxx.blend")

for scene in bpy.data.scenes:
    bpy.context.scene.render.engine = 'CYCLES' 
    bpy.data.scenes["Scene"].cycles.device='GPU' 
    bpy.context.scene.cycles.device = 'GPU'

bpy.context.user_preferences.addons['cycles'].preferences.compute_device_type = "OPENCL"
bpy.context.user_preferences.addons['cycles'].preferences.devices[0].use = True

bpy.ops.render.render(True)
img_path = "/home/xxx/Bilder/test_1.png"
rendered_image = bpy.data.images["Render Result"]
rendered_image.save_render(filepath=img_path)

I am really at a loss here, but i think this could work. I mean even if the GPU for some reason does not work, it should not just fall back to the CPU, but give me some sort of error, right?

uname -r

4.15.1-041501-generic

clinfo

 Platform Name                                   AMD Accelerated Parallel Processing
 Platform Vendor                                 Advanced Micro Devices, Inc.
 Platform Version                                OpenCL 2.1 AMD-APP (2527.3)
 Platform Profile                                FULL_PROFILE
 Platform Extensions                             cl_khr_icd cl_amd_event_callback cl_amd_offline_devices 
 Platform Host timer resolution                  <printPlatformInfo:5: get CL_PLATFORM_HOST_TIMER_RESOLUTION : error -30>
 Platform Extensions function suffix             AMD

EDIT

For reasons unknown to me, installing Radeon RenderPro for Blender has fixed the problem!

https://pro.radeon.com/en/software/prorender/blender/

$\endgroup$
1
$\begingroup$

Looks like you have multiple scenes in your file. To cycle through them and set them all use:

for scene in bpy.data.scenes:
    scene.cycles.device = 'GPU'

bpy.context refers to the to the area of blender which is currently being accessed by the user, not the script loop. If you don't have the file open, I would avoid using bpy.context calls and instead access bpy.data.

$\endgroup$
  • $\begingroup$ Right, that makes sense. I changed the script to do that, but sadly the gpu still is not being used. It always falls back to my cpu. $\endgroup$ – user3922088 Mar 22 '18 at 8:22
  • $\begingroup$ @user3922088 Then the problem must be in setting up the devices in UserPrefs. Your system config is very rare, it will be hard to help. Are you able to run Blender normally on that system with GUI and setup it manually with everything working? I don't see why the script wouldn't work. $\endgroup$ – Jaroslav Jerryno Novotny Mar 22 '18 at 9:10
  • $\begingroup$ I can run it normally, but not when i use this specific OpenCl configuration. Is there no way to set the device via Python? I mean it must be possible on render farms, right? They don't run the gui either. I realize it's rare, but the thing is that the Mesa drivers are superior to AMD's in all regards BUT OpenCL. $\endgroup$ – user3922088 Mar 22 '18 at 9:39
  • $\begingroup$ @user3922088 you would use the command line arguments when rendering remotely for what is needed to set (docs.blender.org/manual/en/dev/advanced/command_line/…). The system setting in UserPrefs is persistent when saved so there is only need to set it once. What do you mean with: I can run it normally, but not when i use this specific OpenCL configuration? $\endgroup$ – Jaroslav Jerryno Novotny Mar 22 '18 at 10:09
  • $\begingroup$ I am running Blender with a custom LD_LIBRARY_PATH to access AMDs OpenCL. If i print the availible devices via Python it shows me the processors and the gpu. I just don't know why it does not let me select it. $\endgroup$ – user3922088 Mar 22 '18 at 10:14
1
$\begingroup$

For reasons unknown to me, installing Radeon RenderPro for Blender has fixed the problem!

https://pro.radeon.com/en/software/prorender/blender/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.