This is an automated email from the ASF dual-hosted git repository.
zhasheng 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 24068c2 fix bug in profiler tutorial when using cpu (#13695)
24068c2 is described below
commit 24068c2d5345865d9d123c014eec79f85122fc30
Author: Soonhwan-Kwon <[email protected]>
AuthorDate: Fri Jan 4 11:34:10 2019 +0900
fix bug in profiler tutorial when using cpu (#13695)
try except approach only goes to ctx=mx.gpu() because
test_utils.list_gpus() at least returns empty array and do not producing error
---
docs/tutorials/python/profiler.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/docs/tutorials/python/profiler.md
b/docs/tutorials/python/profiler.md
index d99bb19..7dcda10 100644
--- a/docs/tutorials/python/profiler.md
+++ b/docs/tutorials/python/profiler.md
@@ -94,10 +94,10 @@ Let's define a method that will run one training iteration
given data and label.
```python
# Use GPU if available
-try:
- mx.test_utils.list_gpus(); ctx = mx.gpu()
-except:
- ctx = mx.cpu()
+if len(mx.test_utils.list_gpus())!=0:
+ ctx=mx.gpu()
+else:
+ ctx=mx.cpu()
# Initialize the parameters with random weights
net.collect_params().initialize(mx.init.Xavier(), ctx=ctx)