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

#14199: catch subprocess.CalledProcessError in get_gpus() #14212

Merged
merged 2 commits into from
Mar 7, 2019

Conversation

frankfliu
Copy link
Contributor

Description

fixes: #14199

Calling subprocess may fail with non-zero code. Catching subprocess.CalledProcessError to avoid get_gpus() crash.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

@frankfliu frankfliu requested a review from szha as a code owner February 20, 2019 17:41
@roywei
Copy link
Member

roywei commented Feb 21, 2019

@roywei
Copy link
Member

roywei commented Feb 21, 2019

@mxnet-label-bot add[Example, Exception Handling, pr-awaiting-review]

@marcoabreu
Copy link
Contributor

marcoabreu commented Feb 21, 2019

Couldn't we replace that with the native version?

https://github.com/apache/incubator-mxnet/blob/fdbc433ffb29c3442b523d32d59f4b44989eac7b/src/c_api/c_api.cc#L130

@frankfliu
Copy link
Contributor Author

frankfliu commented Feb 21, 2019

Couldn't we replace that with the native version?

incubator-mxnet/src/c_api/c_api.cc

Line 130 in fdbc433

int MXGetGPUCount(int* out) {

I changed implemenation to use MXGetGPUCount

@frankfliu frankfliu force-pushed the get_gpus branch 3 times, most recently from 3112cd8 to ae9119c Compare February 21, 2019 23:15
Copy link
Member

@wkcn wkcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question.
Is it continuous for valid GPU ids?

@frankfliu
Copy link
Contributor Author

I have a question.
Is it continuous for valid GPU ids?

Yes, the GPU ids are continuous, and start from 0.
The existing get_gpus() implementation also return a list of gpu ids as range(len(...))

Copy link
Member

@wkcn wkcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!
LGTM : )

Could you please retrigger the CI?

@vandanavk
Copy link
Contributor

@frankfliu could you re-trigger CI? This PR can be merged once CI passes.

1. Added get_gpus() and get_gpu_memory() API to python binding.
2. Update example script to use proper API for getting gpu numbers.
@wkcn wkcn added pr-awaiting-testing PR is reviewed and waiting CI build and test and removed pr-awaiting-review PR is waiting for code review labels Mar 6, 2019
@wkcn wkcn merged commit 49932fa into apache:master Mar 7, 2019
@wkcn
Copy link
Member

wkcn commented Mar 7, 2019

The PR has been merged.
Thanks for your contribution!

@frankfliu frankfliu deleted the get_gpus branch March 8, 2019 16:47
vdantu pushed a commit to vdantu/incubator-mxnet that referenced this pull request Mar 31, 2019
…he#14212)

* Fixes apache#14199: use proper API get number of gpus.

1. Added get_gpus() and get_gpu_memory() API to python binding.
2. Update example script to use proper API for getting gpu numbers.

* retrigger CI
nswamy pushed a commit that referenced this pull request Apr 5, 2019
* Fixes #14199: use proper API get number of gpus.

1. Added get_gpus() and get_gpu_memory() API to python binding.
2. Update example script to use proper API for getting gpu numbers.

* retrigger CI
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
…he#14212)

* Fixes apache#14199: use proper API get number of gpus.

1. Added get_gpus() and get_gpu_memory() API to python binding.
2. Update example script to use proper API for getting gpu numbers.

* retrigger CI
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Example Exception Handling pr-awaiting-testing PR is reviewed and waiting CI build and test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

example/image-classification/common/util.py get_gpus() exception
5 participants