Soonhwan-Kwon opened a new pull request #13695: fix bug in profiler tutorial when using cpu URL: https://github.com/apache/incubator-mxnet/pull/13695 ## Description ## When using cpu only, it produces error because test_utils.list_gpus() always returns at least empty array, and do not goes to the exception. So I used if else statement to get context properly and it works fine. For the reference below is the code for test_utils.py python/mxnet/test_utils.py ```python def list_gpus(): """Return a list of GPUs Returns ------- list of int: If there are n GPUs, then return a list [0,1,...,n-1]. Otherwise returns []. """ re = '' nvidia_smi = ['nvidia-smi', '/usr/bin/nvidia-smi', '/usr/local/nvidia/bin/nvidia-smi'] for cmd in nvidia_smi: try: re = subprocess.check_output([cmd, "-L"], universal_newlines=True) except (subprocess.CalledProcessError, OSError): pass return range(len([i for i in re.split('\n') if 'GPU' in i])) ``` ## Checklist ## ### Essentials ### Please feel free to remove inapplicable items for your PR. - [x] Changes are complete (i.e. I finished coding on this PR)
---------------------------------------------------------------- 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
