This is an automated email from the ASF dual-hosted git repository.

indhub pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 196468d  Corrections to profiling tutorial (#11887)
196468d is described below

commit 196468dedf3135252ed1a98a3db627ffef019473
Author: Thom Lane <[email protected]>
AuthorDate: Sat Jul 28 17:24:42 2018 -0700

    Corrections to profiling tutorial (#11887)
    
    Corrected a race condition with stopping profiling. Added mx.nd.waitall to 
ensure all operations have completed, including GPU operations that might 
otherwise be missing.
    
    Also added alternative code for context selection GPU vs CPU, that had 
error before on machines with nvidia-smi.
---
 docs/tutorials/python/profiler.md | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/docs/tutorials/python/profiler.md 
b/docs/tutorials/python/profiler.md
index 81ecc2a..d99bb19 100644
--- a/docs/tutorials/python/profiler.md
+++ b/docs/tutorials/python/profiler.md
@@ -94,7 +94,10 @@ Let's define a method that will run one training iteration 
given data and label.
 
 ```python
 # Use GPU if available
-ctx = mx.gpu() if mx.test_utils.list_gpus() else mx.cpu()
+try:
+    mx.test_utils.list_gpus(); ctx = mx.gpu()
+except:
+    ctx = mx.cpu()
 
 # Initialize the parameters with random weights
 net.collect_params().initialize(mx.init.Xavier(), ctx=ctx)
@@ -144,7 +147,8 @@ profiler.set_state('run')
 
 run_training_iteration(*next(itr))
 
-# Ask the profiler to stop recording
+# Ask the profiler to stop recording after operations have completed
+mx.nd.waitall()
 profiler.set_state('stop')
 ```
 

Reply via email to