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

Commit

Permalink
Fixes #14199: catch subprocess.CalledProcessError in get_gpus()
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu committed Feb 21, 2019
1 parent fdbc433 commit 8e29e18
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion benchmark/python/control_flow/rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _array(shape, ctx):
def _get_gpus():
try:
re = subprocess.check_output(["nvidia-smi", "-L"], universal_newlines=True)
except OSError:
except (subprocess.CalledProcessError, OSError):
return []
return range(len([i for i in re.split('\n') if 'GPU' in i]))

Expand Down
2 changes: 1 addition & 1 deletion example/image-classification/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ def get_gpus():
"""
try:
re = subprocess.check_output(["nvidia-smi", "-L"], universal_newlines=True)
except OSError:
except (subprocess.CalledProcessError, OSError):
return []
return range(len([i for i in re.split('\n') if 'GPU' in i]))
2 changes: 1 addition & 1 deletion tools/bandwidth/test_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
def get_gpus():
try:
re = subprocess.check_output(["nvidia-smi", "-L"], universal_newlines=True)
except OSError:
except (subprocess.CalledProcessError, OSError):
return ''
gpus = [i for i in re.split('\n') if 'GPU' in i]
return ','.join([str(i) for i in range(len(gpus))])
Expand Down

0 comments on commit 8e29e18

Please sign in to comment.