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/03/01 08:27:45 UTC

[GitHub] Jessespace commented on issue #14220: Qestion bout nd.waitall()

Jessespace commented on issue #14220: Qestion bout nd.waitall()
URL: https://github.com/apache/incubator-mxnet/issues/14220#issuecomment-468584777
 
 
   > You'll want to start 'time_loadimage' after the load and context change has finished: remember that MXNet operations are asynchronous. And it's better to use `wait_to_read()` instead of `waitall()` if you're wanting to time certain operations. And even better still you should check out the [MXNet Profiler](https://mxnet.incubator.apache.org/versions/master/tutorials/python/profiler.html) instead of writing your own profiling code.
   > 
   > ```
   > path = os.path.join(read_dir, '000204.jpg')
   > tic = time.time()
   > img_path = os.path.join(read_dir, path)
   > x, img = data.transforms.presets.yolo.load_test(img_path, short=shape,max_size=shape)
   > x = x.as_in_context(ctx)
   > # block until data load and context switch have completed
   > x.wait_to_read()
   > time_loadimage = time.time() - tic
   > 
   > class_IDs, scores, bounding_boxs = net(x)
   > # block until net has completed
   > bounding_boxs.wait_to_read()
   > all = time.time() - tic
   > 
   > print("every picture time cost:", (all - time_loadimage))
   > print("FPS:", 1.0 / (all - time_loadimage))
   > ```
   
   
   
   > You'll want to start 'time_loadimage' after the load and context change has finished: remember that MXNet operations are asynchronous. And it's better to use `wait_to_read()` instead of `waitall()` if you're wanting to time certain operations. And even better still you should check out the [MXNet Profiler](https://mxnet.incubator.apache.org/versions/master/tutorials/python/profiler.html) instead of writing your own profiling code.
   > 
   > ```
   > path = os.path.join(read_dir, '000204.jpg')
   > tic = time.time()
   > img_path = os.path.join(read_dir, path)
   > x, img = data.transforms.presets.yolo.load_test(img_path, short=shape,max_size=shape)
   > x = x.as_in_context(ctx)
   > # block until data load and context switch have completed
   > x.wait_to_read()
   > time_loadimage = time.time() - tic
   > 
   > class_IDs, scores, bounding_boxs = net(x)
   > # block until net has completed
   > bounding_boxs.wait_to_read()
   > all = time.time() - tic
   > 
   > print("every picture time cost:", (all - time_loadimage))
   > print("FPS:", 1.0 / (all - time_loadimage))
   > ```
   
   I followed your advice and tried to use **profile**. Still some confusion about some places.
   
   **code:**
   profiler.set_state('run')
   tic = time.time()
   
   x, img = data.transforms.presets.yolo.load_test(img_path, short=shape)
   x = x.as_in_context(ctx)
   class_IDs, scores, bounding_boxs = net(x)
   
   bounding_boxs.wait_to_read()
   all = time.time() - tic
   profiler.set_state('stop')
   print("time:", all)
   print(profiler.dumps())`
       
   
   **Result:**
      1. time: 5.4537177085876465
      2.  [profile result:](https://github.com/Jessespace/MXNet-Learning/blob/master/profile.png)
   
   I add  all the **MXNET_C_API time** ,it is about the 5.4s which similar to 5.45s using **tic toc**. But I can't understand **Device Storage time** and **operator time** ,they take too long.
      

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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