indhub closed pull request #11887: Corrections to profiling tutorial
URL: https://github.com/apache/incubator-mxnet/pull/11887
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/docs/tutorials/python/profiler.md
b/docs/tutorials/python/profiler.md
index 81ecc2a84ed..d99bb19ee02 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')
```
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services