# GPU and Multi-CPU computations in Python in Blender 2.8+ with Cycles

Greetings beautiful Blender community,

Is there a way to force certain sets of computations to occur on certain devices?

For example code to parallelize, consider:

for h in horizontal_pixels:
for v in vertical_pixels:
bpy.context.scene.ray_cast()


In Tensorflow, e.g., it's possible to do this like so:

with tf.device('/cpu:0'):
# some computations over here

with tf.device('/cpu:1'):
# more computations over there

with tf.device('/gpu:0'):
# computation computation everywhere


I've read that multiprocessing has not historically worked with Blender, that people have worked around this by launching separate programs.

Supposing my target function to parallelize is just the raycast function (and my inputs are not already computed under the hood by Cycles), maybe there is a way to use existing parallelization code for rendering, e.g. which may exist somewhere in C++?

• I'm assuming you could import the tensorflow module to blender python and use it the way you usually would – avatar Jun 28 at 11:46