dcmaddix opened a new issue #18865:
URL: https://github.com/apache/incubator-mxnet/issues/18865


   ## Description
   I am trying to fix the random seed across multiple cpus and followed the 
example to pass `ctx` here : 
https://mxnet.apache.org/versions/1.6/api/python/docs/api/mxnet/random/index.html
 and the example code works but it seems order dependent.  See the output 
below.  If I call mx.random.seed(128, ctx=mx.cpu(0)) and mx.random.seed(128, 
ctx=mx.cpu(1)), it does not work.  Also is this the only way to loop over all 
the num_cpus and set each ctx?
   
   ## To Reproduce
   `mx.random.seed(128, ctx=mx.cpu(0))
   print(mx.nd.random.normal(shape=(2,2), ctx=mx.cpu(0)).asnumpy())
   [[ 0.47400656  0.20251541]
    [ 1.3648157  -1.4962182 ]]
   mx.random.seed(128, ctx=mx.cpu(1))
   print(mx.nd.random.normal(shape=(2,2), ctx=mx.cpu(1)).asnumpy())
   [[ 0.47400656  0.20251541]
    [ 1.3648157  -1.4962182 ]]
   `
   `mx.random.seed(128, ctx=mx.cpu(0))
   mx.random.seed(128, ctx=mx.cpu(1))
   print(mx.nd.random.normal(shape=(2,2), ctx=mx.cpu(0)).asnumpy())
   [[ 0.47400656  0.20251541]
    [ 1.3648157  -1.4962182 ]]
   print(mx.nd.random.normal(shape=(2,2), ctx=mx.cpu(1)).asnumpy())
   [[ 1.0954498  -0.20808885]
    [ 1.590508   -0.41777727]]
   `
   The second arrays do not match and I am not sure why because the seed is 
set.  We also see this when trying to use multi-processing in our algorithms 
and the numbers are very different even for fixed seed.  Above is a simple 
representative example.
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to