Thanks for the quick reply. It does indeed succeed if I delay the
import. I guess there is no way to force reloading of the OpenCL
bindings. I will have to try and workaround by delaying imports of
pyopencl as long as possible
On Mon, Nov 26, 2012 at 7:09 PM, Andreas Kloeckner
Jonathan Hunt <hunt(a)braincorporation.com> writes:
> If I run the code below (using pyopencl after fork) I get an
> LogicError: clGetContextInfo failed: invalid context. I guess what is
> happening is that the CL library needs to be initialized again in a
> new process.
> I have tried various combinations of reload(cl) reload(cl._cl) and
> calling cl.__init__ etc to no avail.
> The reason I want to this is that I'm using pytest with --boxed option
> (every test is run in a seperate process) (my tests don't call
> os.fork() explicitly - that's just to recreate the error without
> Any tips on how to workaround this appreciated. This is OS X 10.8.2
> (with Apple CL).
Uh, that's pretty dire. "import pyopencl" doesn't call a single OpenCL
function. It just loads the OpenCL C library. If that alone destroys
fork(), then there's little that it as a library can do. If you can,
perhaps import pyopencl after you fork...?