From 208beaad95db716ca2b9e2025ce519150cf39d13 Mon Sep 17 00:00:00 2001 From: Kellen Sunderland Date: Tue, 15 Jan 2019 21:43:57 -0800 Subject: [PATCH] fix bug in profiler tutorial when using cpu (#13899) 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 d99bb19ee029..7dcda10f11b8 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)