Hi PyOpenCLers,
I ran into an unexpected problem when using the multiprocessing library
with pyopencl.
My intent was to create a multi-process application, where an initial
python process uses multiprocessing.Process to create a number of
sub-processes, of which just one uses pyopencl.
The unexpected problem I found was that if the initial process imports
pyopencl, that interferes with the subprocess using pyopencl, at the
point that the command queue is created. The error is "RuntimeError:
CommandQueue failed: out of host memory". Here's a test program that
illustrates the problem.
---------------------- Cut -------------------------------------------
import multiprocessing
# Comment out to avoid "out of host memory" error.
import pyopencl
def main():
proc = multiprocessing.Process(target=cl_setup)
proc.start()
def cl_setup():
import pyopencl as cl
platform = cl.get_platforms()[0]
# Change GPU to CPU to avoid "out of host memory" error.
devices = platform.get_devices(cl.device_type.GPU)
ctx = cl.Context(devices)
device = devices[0]
cmd_q = cl.CommandQueue(ctx, device)
print "Success. Your cmd_q is %s." % cmd_q
if __name__ == '__main__':
main()
---------------------- Cut -------------------------------------------
Note that the root process just imports pyopencl. It never references
it, but something about the import causes a problem for the sub-process
that actually wants to do pyopencl things.
I can work around this problem by not importing pyopencl in the root
process, but I thought it was unexpected enough that I should report it.
Interestingly, this problem does not occur if I use cl.device_type.CPU
instead of cl.device_type.GPU.
I looked through pyopencl/__init__.py but didn't see anything obvious
that would cause this behavior.
My environment is Ubuntu 14.04, AMD APP 1445.5, Python 2.7.6, and the
latest from pyopencl's master branch (commit 2382347).
Finally, here's an actual traceback of the error:
[orion]brix:/brix/src/orion/src$ python cl_mp.py
Process Process-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in
_bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "cl_mp.py", line 19, in cl_setup
cmd_q = cl.CommandQueue(ctx, device)
RuntimeError: CommandQueue failed: out of host memory
[orion]brix:/brix/src/orion/src$ python
Mark
_______________________________________________
PyOpenCL mailing list
PyOpenCL@tiker.net
http://lists.tiker.net/listinfo/pyopencl