[Numpy-discussion] numpy.random and multiprocessing

Gael Varoquaux gael.varoquaux@normalesup....
Thu Dec 11 11:49:03 CST 2008


On Fri, Dec 12, 2008 at 02:29:55AM +0900, David Cournapeau wrote:
> The seed could be explicitly set in each task, no ?

> def task(x):
>     np.random.seed()
>     return np.random.random(x)

Yes. The problem is trivial to solve, once you are aware of it. Just like
the integer division problems we used to have back in the days where
zeros, ones, ... returned ineger arrays. The point is that people will
run into that problem and loose a lot of time. So we must make it so that
they don't by mistake land in this situation, but purposely.

One solution is to check the PID of the process when the PRNG is called,
and reseed if it has changed. As pointed out, the danger of this is that
this is magic, so there needs to be an option to turn this off.

Gaël


More information about the Numpy-discussion mailing list