# How do I get Cycles to use GPU on a linux server?

Inspired by this question: Enabling GPU rendering for Cycles?

I have access to a Linux server that is equipped with GeForce GTX TITAN X. Now Cycles still renders everything with CPU. How can I get it to exploit the GPU?

Since I am talking about a Linux server, I guess there are two steps towards this goal:

1. How to get the GPU ID or identifier with Unix commands so that I can refer to it in Blender?
2. How to use Python to enable GPU computations?

For enabling the device for use, see bpy.context.user_preferences.system.compute_device_type and
bpy.context.user_preferences.system.compute_device
.

To check these from a shell, put the python you wish to execute in a file and run

blender --background --python <file.py>


Or, more concisely for quick tests,

blender -b --python-expr 'import bpy; <python code here>'


For convenience, here's a script which will print the possible and current values of compute_device_type and compute_device:

import bpy

sysp = bpy.context.user_preferences.system

devt = sysp.compute_device_type
dev = sysp.compute_device

# get list of possible values of enum, see http://blender.stackexchange.com/a/2268/599
devt_list = sysp.bl_rna.properties['compute_device_type'].enum_items.keys()
dev_list = sysp.bl_rna.properties['compute_device'].enum_items.keys()

# pretty print
lines=[
("Property", "Value", "Possible Values"),
("Device Type:", devt, str(devt_list)),
("Device:", dev, str(dev_list)),
]
print("\nGPU compute configuration:")
for l in lines:
print("{0:<20} {1:<20} {2:<50}".format(*l))


If CUDA shows up in the possible values for device type, then enabling the device should be as simple as doing something like this in python:

devt = sysp.compute_device_type = 'CUDA'
dev = sysp.compute_device = 'CUDA_0'


To find the identifier for the device, you can use the script above with a line to set compute_device_type to CUDA before getting the list of possible devices.

Once that's all enabled we must still tell cycles to actually use it; to do this set bpy.context.scene.cycles.device to GPU.

• Very clear answer; +1. For me, Device Type: NONE ['NONE', 'CUDA'] . What does this mean? My device type is None, and compute device is CUDA? Thanks! Dec 30 '16 at 4:49
• @SibbsGambling Ah, that wasn't layed out very clearly at all. There are two lines, the first is the "device type" property, its current value, and the possible selections (this is for picking between opencl and cuda). The second line shows the selected "device" (which, if device type is none, should also be none). The "device type" will have no option available besides NONE if there is a lack of detected devices for either opencl or cuda, so that fact that cuda is an option suggests you are in good shape. I've added headers to the little table printed by the snippet, hopefully that clarifies
– gandalf3
Dec 30 '16 at 6:46
• Awesome! So I have devices ['CUDA_MULTI_0', 'CUDA_0', 'CUDA_1', 'CUDA_2', 'CUDA_3'], and now the GPU gets to run! Dec 30 '16 at 17:28
• But... why the GPU computation is much slower than the CPU computations to render the same scene? Dec 30 '16 at 18:39
• @SibbsGambling Sorry about the delay.. What tile size are you using? Does a larger size help (maybe 512)?
– gandalf3
Jan 4 '17 at 6:21