Using the following in a Python script node to globally enable OpenCl in my scene
n=hou.pwd()defset_opencl(parent_node,parm_value):fornodeinparent_node.allSubChildren():forpinnode.parms():ifp.name()=='opencl':try:p.set(parm_value)excepthou.PermissionError:#this handles the case that the parm is inside of a locked .otlpasshou.session.set_opencl(hou.node('/obj/sim'),1);
but get the following error
Attribute error: ‘module’ object has no attribute ‘set_opencl’
I assume you entered the code for that function directly into a Python Shell window? If so, that function is not defined in the hou.session module, it is defined as a global in the context of that python shell. So you should be able to run:
set_opencl(hou.node('/obj/sim'),1)
But I presume you actually want this function defined in the hou.session module so that it gets saved to the hip file and is available the next time you load this hip file. To do this, go to Windows -> Python Source Editor. Make sure the “Source File” is set to “hou.session module”, and enter your function in that window. Then you'll be able to run: