You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/06/13 03:19:27 UTC

[GitHub] [incubator-mxnet] chinakook opened a new issue #15231: mxnet.nd.random.multinomial is very slow on CPU and stucked on GPU

chinakook opened a new issue #15231: mxnet.nd.random.multinomial is very slow on CPU and stucked on GPU
URL: https://github.com/apache/incubator-mxnet/issues/15231
 
 
   ```python
   import time
   import numpy as np
   import mxnet as mx
   
   
   p = [1 / 300000.] * 300000
   
   probs = np.array(p)
   t0 = time.time()
   sample_times = np.random.multinomial(len(probs), np.array(probs))
   t1 = time.time()
   print("Numpy MultiNomial Time", t1 - t0)
   
   probs = mx.nd.array(p, ctx=mx.cpu())
   t0 = time.time()
   indices = mx.nd.random.multinomial(probs, len(probs))
   mx.nd.waitall()
   t1 = time.time()
   print("MXNet CPU MultiNomial Time", t1 - t0)
   
   # stucked
   # probs = mx.nd.array(p, ctx=mx.gpu(0))
   # t0 = time.time()
   # indices = mx.nd.random.multinomial(probs, len(probs))
   # mx.nd.waitall()
   # t1 = time.time()
   # print("MXNet GPU MultiNomial Time", t1 - t0)
   
   ```
   
   The result is
   ```
   Numpy MultiNomial Time 0.01881909
   MXNet GPU MultiNomial Time 43.93881797
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services