AttributeError: 'ConfigDict' object has no attribute 'device'
See original GitHub issueDescribe 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
- What command or script did you run?
python tools/train.py configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
- What config dir you run?
configs/pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py
- Did you make any modifications on the code or config? Did you understand what you have modified?
No, I just follow the tutorials.
- What dataset did you use?
KITTI Dataset. I have created it by following the markdown file called kitti_det.md.
Environment
- 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
- 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:
- Created a year ago
- Comments:8 (2 by maintainers)
I fixed just adding in my config file:
device = 'cuda'
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()