Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix bug in profiler tutorial when using cpu (#13899)
Browse files Browse the repository at this point in the history
try except approach only goes to ctx=mx.gpu() because test_utils.list_gpus() at least returns empty array and do not producing error
  • Loading branch information
KellenSunderland authored and szha committed Jan 16, 2019
1 parent bf15539 commit 208beaa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/tutorials/python/profiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 208beaa

Please sign in to comment.