Enabling gpu rendering by command line

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Posts: 6
Joined: Sat Mar 10, 2012 1:04 pm

Enabling gpu rendering by command line

Postby LeHibou » Thu Sep 06, 2012 1:37 pm

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: 15
Joined: Mon Dec 10, 2007 1:52 am
Location: arkansas

not sure but...

Postby dustractor » Thu Sep 20, 2012 10:43 pm

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__":

Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests