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

AttributeError: 'ConfigDict' object has no attribute 'device' #1445

Closed
AuntDia opened this issue Apr 29, 2022 · 8 comments
Closed

AttributeError: 'ConfigDict' object has no attribute 'device' #1445

AuntDia opened this issue Apr 29, 2022 · 8 comments

Comments

@AuntDia
Copy link

AuntDia commented Apr 29, 2022

Describe the issue

A clear and concise description of what the problem you meet and what have you done.

I want to train with existing models and standard datasets, so I follow the script "python tools/train.py ${CONFIG_FILE} [optional arguments]" and input the legal command. But it didn't work. Terminal gave the info like this:
[File "I:\Ana\envs\open-mmlab\lib\site-packages\mmcv\utils\config.py", line 513, in getattr
return getattr(self._cfg_dict, name)
File "I:\Ana\envs\open-mmlab\lib\site-packages\mmcv\utils\config.py", line 49, in getattr
raise ex
AttributeError: 'ConfigDict' object has no attribute 'device']
Frankly, I can't solve it, so I ask for help.

Reproduction

  1. What command or script did you run?
python tools/train.py configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
  1. What config dir you run?
configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
No, I just follow the tutorials.
  1. What dataset did you use?
KITTI Dataset. I have created it by following the markdown file called kitti_det.md.

Environment

  1. Please collect necessary environment information and paste it here.
    sys.platform: win32
    Python: 3.7.13
    CUDA available: True
    GPU 0: NVIDIA GeForce RTX 3060
    PyTorch: 1.8.2
    TorchVision: 0.2.2
    OpenCV: 4.5.5
    MMCV: 1.5.0
    MMCV Compiler: MSVC 192930137
    MMCV CUDA Compiler: 11.1
    MMDetection: 2.24.0
    MMSegmentation: 0.23.0
    MMDetection3D: 1.0.0rc1+ff159fe
  2. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Results

If applicable, paste the related results here, e.g., what you expect and what you get.

Just help me solve this problem and accomplish this model trainning successfully.

Issue fix

If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

@alanxuefei
Copy link

I encounter the same issue.

@alanxuefei
Copy link

MMDetection: 2.24.0 can be downgraded to 2.23.0.
Because of the following changes.

https://github.com/open-mmlab/mmdetection/blame/master/mmdet/apis/train.py

@Xiangxu-0103
Copy link
Collaborator

Yeh, current version can not be well compatible with mmdet v2.24.0, and the PR #1412 may cause potential bug when training. This will be fixed soon.

@JusticeGL
Copy link

I encounter the same issue when I trainning deepsort

@Tziming
Copy link

Tziming commented May 2, 2022

I fixed it by this way,maybe it's help for you

  • First, add a function in train.py

    def get_device():
    """Returns an available device, cpu, cuda or mlu."""
    is_device_available = {
    'cuda': torch.cuda.is_available(),
    }
    device_list = [k for k, v in is_device_available.items() if v]
    return device_list[0] if len(device_list) == 1 else 'cpu'

  • Second, add this line after cfg = Config.fromfile(args.config) in train.py

    cfg["device"] = get_device()

@Xiangxu-0103
Copy link
Collaborator

I think the potential bug has been fixed in #1443.

@edu010101
Copy link

I fixed just adding in my config file:
device = 'cuda'

@zzzzzz-ddddd
Copy link

MMDetection: 2.24.0 can be downgraded to 2.23.0.
https://github.com/open-mmlab/mmdetection/blame/master/mmdet/apis/train.py

How to reduce mmdetection2.24 to 2.23? Thank you for your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants