question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
edu010101commented, May 11, 2022

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

9reactions
Tzimingcommented, 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()

Read more comments on GitHub >

github_iconTop Results From Across the Web

'ConfigDict' object has no attribute 'device' #7901 - GitHub
I was recently able to successfully fine-tune mask r-cnn and mask scoring r-cnn on my costume dataset. Training and inference both worked ...
Read more >
How to fix AttributeError: 'ConfigDict' object has no attribute ...
I have no idea what is wrong with the code and why it is not working. from argparse import ArgumentParser from mmdet.apis import...
Read more >
AttributeError: 'ConfigDict' object has no attribute 'device'
mmdetection训练自己的coco数据集通过命令行运行tools/train.py文件时,报错:AttributeError: 'ConfigDict' object has no attribute 'device'
Read more >
Changelog — MMDetection 2.26.0 documentation
Fix single GPU distributed training of cuda device specifying (#8176) ... Fix PALETTE AttributeError in downstream task (#7230) ...
Read more >
错误处理-mmdetection-AttributeError: 'ConfigDict' object has ...
错误处理-mmdetection-AttributeError: 'ConfigDict' object has no attribute 'log_level'. 心中带点小风骚 • 2022年5月22日 下午3:04 • 问题解决 • 阅读 499.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found