Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhance] New-style CPU training and inference. #674

Merged
merged 2 commits into from
Jan 30, 2022

Conversation

mzr1996
Copy link
Member

@mzr1996 mzr1996 commented Jan 26, 2022

Motivation

Refers to open-mmlab/mmdetection#7016, and it's based on open-mmlab/mmcv#1621

Modification

As the title.

BC-breaking (Optional)

No, the old style is reserved but deprecated and it will be removed after three months.

Use cases (Optional)

Old style CPU training

python tools/train.py $CONFIG --device cpu

New style CPU training

export CUDA_VISIBLE_DEVICES=-1
python tools/train.py $CONFIG

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
  • CLA has been signed and all committers have signed the CLA in this PR.

@mzr1996 mzr1996 requested a review from Ezra-Yu January 26, 2022 11:23
@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #674 (78bdf7d) into dev (a451d63) will increase coverage by 0.88%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #674      +/-   ##
==========================================
+ Coverage   82.27%   83.15%   +0.88%     
==========================================
  Files         120      126       +6     
  Lines        7045     7630     +585     
  Branches     1228     1332     +104     
==========================================
+ Hits         5796     6345     +549     
- Misses       1075     1095      +20     
- Partials      174      190      +16     
Flag Coverage Δ
unittests 83.15% <0.00%> (+0.88%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmcls/apis/train.py 20.73% <0.00%> (-0.52%) ⬇️
mmcls/utils/__init__.py 100.00% <0.00%> (ø)
mmcls/models/necks/__init__.py 100.00% <0.00%> (ø)
mmcls/models/utils/__init__.py 100.00% <0.00%> (ø)
mmcls/models/backbones/resnet.py 100.00% <0.00%> (ø)
mmcls/models/backbones/__init__.py 100.00% <0.00%> (ø)
mmcls/models/backbones/hrnet.py 87.16% <0.00%> (ø)
mmcls/models/backbones/convnext.py 94.78% <0.00%> (ø)
mmcls/utils/setup_env.py 95.45% <0.00%> (ø)
mmcls/models/necks/hr_fuse.py 100.00% <0.00%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a451d63...78bdf7d. Read the comment docs.

@@ -87,17 +87,20 @@ def parse_args():
action=DictAction,
help='custom options for show_result. key-value pair in xxx=yyy.'
'Check available options in `model.show_result`.')
parser.add_argument(
'--device', default=None, help='device used for testing. (Deprecated)')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not keep this interface?
I prefer the use xxx --device cpu rather than export CUDA_VISIBLE_DEVICES=-1 xxxx.

the command is simpler.

Copy link
Member Author

Choose a reason for hiding this comment

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

To use MMDataParallel for CPU training/test, we need to specify CUDA_VISILBE_DEVICES=-1, and in that situation, the --device argument is useless.

@Ezra-Yu Ezra-Yu self-requested a review January 29, 2022 09:35
@mzr1996 mzr1996 merged commit 8ef5aed into open-mmlab:dev Jan 30, 2022
Ezra-Yu pushed a commit to Ezra-Yu/mmclassification that referenced this pull request Feb 14, 2022
* [Enhance] New-style CPU training and inference.

* Add version check in CPU training/test
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
* [Enhance] New-style CPU training and inference.

* Add version check in CPU training/test
@mzr1996 mzr1996 deleted the cpu-train branch December 7, 2022 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants