[PyCUDA] Multiprocessing + PyCUDA + MAC OSX

Andreas Kloeckner lists at informa.tiker.net
Mon Apr 30 09:44:01 PDT 2012


On Fri, 27 Apr 2012 22:09:47 -0400, Andrew Cron <andrew.j.cron at gmail.com> wrote:
> I'm working on some multi GPU software, and I've run into a snag on
> OSX. (Note that this works on Linux.) Here's some sample code:
> 
> import multiprocessing
> import pycuda.driver as drv
> drv.init()  ## COMMENT THIS LINE AND IT RUNS FINE
> 
> if __name__=="__main__":
> 
>     def tar():
> 	print drv.Device(0).make_context()
> 
>     thd = multiprocessing.Process(target=tar)
> 
>     thd.start()
>     thd.join()
> 
> This code produces the following error:
> LogicError: cuDeviceGet failed: not initialized
> 
> I want to be able to keep the first "drv.init()" so that my code will
> play nice with other pycuda software on the host thread. My guess is
> the source of the issue is related to how multiprocessing clones the
> parent process. It probably does something weird to pycuda.
> 
> Any suggestions? Thanks a ton in advanced for your help!!

Turns out I asked this exact question of Nvidia at some point in late
'08:

http://forums.nvidia.com/index.php?showtopic=83219

Judging from the replies I got, I don't think this is defined behavior
in any sense, so the fact that it works on Linux is pure coincidence. I
think you'll have to stick to fork-then-init, unfortunately.

Andreas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20120430/2281a574/attachment.pgp>


More information about the PyCUDA mailing list