Enabling gpu rendering by command line

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Sat Mar 10, 2012 1:04 pm

Enabling gpu rendering by command line

Post by LeHibou »

Hi !

I don't have any chance enabling gpu renderin gon my laptop. But I can take advantage of external compute power.

I would like to enable my .blend to have gpu rendering even if I cannot activate it on my laptop.

The following python code won't work :

Code: Select all

import bpy

bpy.context.user_preferences.system.compute_device_type = 'CUDA'
How could I do this ?

I really need this, really.

Thanks !


Posts: 0
Joined: Mon Dec 10, 2007 1:52 am
Location: arkansas

not sure but...

Post by dustractor »

I think the problem is the order that scripts run at launch. Cycles is an addon -> addons are loaded after startup folder scripts.

Perhaps some way to delay until blender is finished launching, make sure cycles is loaded/activated, then try your line of code line?

I have my prefs set up in a startup script, all works except the enabling cuda part.

heres that prefs.py:

Code: Select all

import bpy
AUTHOR = 'dust'
def set_prefs(context):

    prefs = context.user_preferences

    filepaths = prefs.filepaths
    filepaths.font_directory = "/Library/Fonts/"
    filepaths.animation_player= "/Applications/djv-0.9.0.app/Contents/MacOS/djv-0.9.0"
    filepaths.animation_player_preset = "DJV"
    filepaths.image_editor = '/Applications/GIMP.app'
    filepaths.texture_directory = '/Users/dust/Pictures/texture/'
    filepaths.render_output_directory = '/Users/dust/Desktop/'
    filepaths.show_thumbnails = True

    inputs = prefs.inputs

    inputs.use_mouse_continuous = True

    view = prefs.view

    view.show_splash = False
    view.use_auto_perspective = True
    system = prefs.system

    system.compute_device_type = 'CUDA'
    system.author = AUTHOR

    edit = prefs.edit

    edit.use_enter_edit_mode = True
    edit.object_align = 'VIEW'

def register():
    if not bpy.context.user_preferences.system.author:
        print('setting preferences for author:',AUTHOR)

if __name__ == "__main__":

Post Reply