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

[Fix] Fixed device_id in tools/test.py for the CPU. #58

Merged
merged 6 commits into from
Jan 13, 2022
Merged

[Fix] Fixed device_id in tools/test.py for the CPU. #58

merged 6 commits into from
Jan 13, 2022

Conversation

SemyonBevzuk
Copy link
Collaborator

Motivation

It was found that tools/test.py with argument --device cpu crashes with the following error:

2022-01-11 01:45:25,318 - mmdeploy - INFO - Successfully loaded onnxruntime custom ops from             /home/sbevzyuk/mmdeployment_dir/MMDeploy/build/lib/libmmdeploy_onnxruntime_ops.so
Traceback (most recent call last):
  File "/home/sbevzyuk/mmdeployment_dir/MMDeploy/tools/test.py", line 141, in <module>
    main()
  File "/home/sbevzyuk/mmdeployment_dir/MMDeploy/tools/test.py", line 112, in main
    model = MMDataParallel(model, device_ids=[device_id])
  File "/home/sbevzyuk/anaconda3/envs/mmdeployment/lib/python3.7/site-packages/mmcv/parallel/data_parallel.py", line 35, in __init__
    super(MMDataParallel, self).__init__(*args, dim=dim, **kwargs)
  File "/home/sbevzyuk/anaconda3/envs/mmdeployment/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 140, in __init__
    self.src_device_obj = torch.device(device_type, self.device_ids[0])
RuntimeError: Device index must not be negative`

This PR proposes a fix for this problem.

Modification

  • mmdeploy/backend/openvino/wrapper.py: Fixed work with the dictionary for Python 3.8.
  • mmdeploy/utils/device.py: The documentation of the parse_device_id function was updated.
  • tests/test_utils/test_util.py: Added tests for function parse_device_id.
  • tools/test.py: Added fix for cpu.

@SemyonBevzuk SemyonBevzuk added the bug Something isn't working label Jan 10, 2022
@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #58 (d5f463d) into master (fbce75e) will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
+ Coverage   67.46%   67.60%   +0.13%     
==========================================
  Files         173      173              
  Lines        5733     5735       +2     
  Branches      910      910              
==========================================
+ Hits         3868     3877       +9     
+ Misses       1583     1578       -5     
+ Partials      282      280       -2     
Flag Coverage Δ
unittests 67.60% <100.00%> (+0.13%) ⬆️

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

Impacted Files Coverage Δ
mmdeploy/backend/openvino/wrapper.py 100.00% <100.00%> (ø)
mmdeploy/utils/device.py 100.00% <100.00%> (+53.84%) ⬆️

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 fbce75e...d5f463d. Read the comment docs.

tools/test.py Outdated Show resolved Hide resolved
mmdeploy/utils/device.py Show resolved Hide resolved
Copy link
Member

@AllentDan AllentDan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@grimoire grimoire left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@RunningLeon RunningLeon left a comment

Choose a reason for hiding this comment

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

LGTM

@RunningLeon RunningLeon merged commit 997d111 into open-mmlab:master Jan 13, 2022
@SemyonBevzuk SemyonBevzuk deleted the sb/fix_test_device branch January 13, 2022 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants