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

KeyError: 'model_id' #6

Open
saadjumani opened this issue Jun 16, 2024 · 7 comments
Open

KeyError: 'model_id' #6

saadjumani opened this issue Jun 16, 2024 · 7 comments

Comments

@saadjumani
Copy link

Hi, I am trying to run the model on my local machine (windows 10 PC with AMD Ryzen 5 CPU, Nvidia 2060S GPU). I dont need to train the model, just to try and run with last checkpoint.

I try to run this the following way: python main.py predict --data=Matterport3D --model=PanFusion --ckpt_path=last

I get the following error traceback

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu)
    Python  3.9.13 (you have 3.9.19)
  Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
  Memory-efficient attention, SwiGLU, sparse and more won't be available.
  Set XFORMERS_MORE_DETAILS=1 for more details
Seed set to 0
Traceback (most recent call last):
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\fabric\utilities\data.py", line 487, in __getattr__
    return self[key]
KeyError: 'model_id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 952, in adapt_typehints
    val = adapt_class_type(val, serialize, instantiate_classes, sub_add_kwargs, prev_val=prev_val)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 1184, in adapt_class_type
    return instantiator_fn(val_class, **{**init_args, **dict_kwargs})
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_common.py", line 158, in __call__
    return instantiator(class_type, *args, **kwargs)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\pytorch\cli.py", line 798, in __call__
    return class_type(*args, **kwargs)
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\models\pano\PanFusion.py", line 20, in __init__
    super().__init__(**kwargs)
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\models\pano\PanoGenerator.py", line 84, in __init__
    self.load_shared()
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\models\pano\PanoGenerator.py", line 118, in load_shared
    self.hparams.model_id, subfolder="tokenizer", torch_dtype=torch.float16, use_safetensors=True)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\fabric\utilities\data.py", line 489, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{key}'") from e
AttributeError: 'AttributeDict' object has no attribute 'model_id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\main.py", line 76, in <module>
    cli_main()
  File "D:\Softwares\VRImagegenerators\PanFusion\PanFusion\main.py", line 57, in cli_main
    cli = MyLightningCLI(
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\pytorch\cli.py", line 391, in __init__
    self.instantiate_classes()
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\lightning\pytorch\cli.py", line 557, in instantiate_classes
    self.config_init = self.parser.instantiate_classes(self.config)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_deprecated.py", line 141, in patched_instantiate_classes
    cfg = self._unpatched_instantiate_classes(cfg, **kwargs)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_core.py", line 1191, in instantiate_classes
    cfg[subcommand] = subparser.instantiate_classes(cfg[subcommand], instantiate_groups=instantiate_groups)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_deprecated.py", line 141, in patched_instantiate_classes
    cfg = self._unpatched_instantiate_classes(cfg, **kwargs)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_core.py", line 1182, in instantiate_classes
    parent[key] = component.instantiate_classes(value)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 565, in instantiate_classes
    value[num] = adapt_typehints(
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 956, in adapt_typehints
    raise_unexpected_value(f"Problem with given class_path {class_path!r}:\n{error}", exception=ex)
  File "D:\Softwares\Anaconda\envs\panfusion\lib\site-packages\jsonargparse\_typehints.py", line 634, in raise_unexpected_value
    raise ValueError(message) from exception
ValueError: Problem with given class_path 'models.PanFusion':
  'AttributeDict' object has no attribute 'model_id'
@YacratesWyh
Copy link

same

@YacratesWyh
Copy link

YacratesWyh commented Jun 18, 2024

I've solved this. Two problems potential:

  1. You may not using python 3.9. 3.12 would make xformers not compatible, it's fatal when I tried to install it only with torch 2.3.0, not worked as it claimed.
  2. u need to install huggingface_hub or else to lanch this transformers install. Just try any diffusers start tutorial would solve this, before running it. It may work for someone because they've already downloaded this in .cache so it wouldn't be a problem. But I've done it in another directory.
    I think it's solved. Key is not to install the loose requirement.txt.

In your log, it's clear that you install not the correct way.

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu)
    Python  3.9.13 (you have 3.9.19)

This shows that you are using cpu And xformers and huggingface may not working. In my case this hints 2.3.0+cu121 and python 3.12

@Leonever
Copy link

Leonever commented Aug 4, 2024

I've solved this. Two problems potential:

  1. You may not using python 3.9. 3.12 would make xformers not compatible, it's fatal when I tried to install it only with torch 2.3.0, not worked as it claimed.
  2. u need to install huggingface_hub or else to lanch this transformers install. Just try any diffusers start tutorial would solve this, before running it. It may work for someone because they've already downloaded this in .cache so it wouldn't be a problem. But I've done it in another directory.
    I think it's solved. Key is not to install the loose requirement.txt.

In your log, it's clear that you install not the correct way.

WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
    PyTorch 2.0.1+cu118 with CUDA 1108 (you have 2.0.1+cpu)
    Python  3.9.13 (you have 3.9.19)

This shows that you are using cpu And xformers and huggingface may not working. In my case this hints 2.3.0+cu121 and python 3.12

I have met the same question, but i do not know how to deal with it.
Seed set to 0
Traceback (most recent call last):
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/lightning/fabric/utilities/data.py", line 487, in getattr
return self[key]
KeyError: 'model_id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_typehints.py", line 1037, in adapt_typehints
val = adapt_class_type(val, serialize, instantiate_classes, sub_add_kwargs, prev_val=prev_val)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_typehints.py", line 1315, in adapt_class_type
return instantiator_fn(val_class, **{**init_args, **dict_kwargs})
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_common.py", line 158, in call
return instantiator(class_type, *args, **kwargs)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/lightning/pytorch/cli.py", line 798, in call
return class_type(*args, **kwargs)
File "/root/autodl-tmp/PanFusion/models/pano/PanFusion.py", line 20, in init
super().init(**kwargs)
File "/root/autodl-tmp/PanFusion/models/pano/PanoGenerator.py", line 84, in init
self.load_shared()
File "/root/autodl-tmp/PanFusion/models/pano/PanoGenerator.py", line 118, in load_shared
self.hparams.model_id, subfolder="tokenizer", torch_dtype=torch.float16, use_safetensors=True)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/lightning/fabric/utilities/data.py", line 489, in getattr
raise AttributeError(f"'{type(self).name}' object has no attribute '{key}'") from e
AttributeError: 'AttributeDict' object has no attribute 'model_id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/autodl-tmp/PanFusion/main.py", line 76, in
cli_main()
File "/root/autodl-tmp/PanFusion/main.py", line 57, in cli_main
cli = MyLightningCLI(
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/lightning/pytorch/cli.py", line 391, in init
self.instantiate_classes()
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/lightning/pytorch/cli.py", line 557, in instantiate_classes
self.config_init = self.parser.instantiate_classes(self.config)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_deprecated.py", line 140, in patched_instantiate_classes
cfg = self._unpatched_instantiate_classes(cfg, **kwargs)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_core.py", line 1196, in instantiate_classes
cfg[subcommand] = subparser.instantiate_classes(cfg[subcommand], instantiate_groups=instantiate_groups)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_deprecated.py", line 140, in patched_instantiate_classes
cfg = self._unpatched_instantiate_classes(cfg, **kwargs)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_core.py", line 1187, in instantiate_classes
parent[key] = component.instantiate_classes(value)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_typehints.py", line 600, in instantiate_classes
value[num] = adapt_typehints(
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_typehints.py", line 1041, in adapt_typehints
raise_unexpected_value(f"Problem with given class_path {class_path!r}:\n{error}", exception=ex)
File "/root/miniconda3/envs/panfusion/lib/python3.9/site-packages/jsonargparse/_typehints.py", line 702, in raise_unexpected_value
raise ValueError(message) from exception
ValueError: Problem with given class_path 'models.PanFusion':
'AttributeDict' object has no attribute 'model_id'

@tonylu435
Copy link

Same problem. Without Xformer errors and exactly the same error as Leonever.

@IssacandLi
Copy link

Same question as Leonever, without Xformer errors.

@IssacandLi
Copy link

tonylu435
Hi, i have solved this problem, you need to install the packages with strict.yaml file, and also, you need to make sure your pytorch verson can be work with your cuda version.

@guanfuqi
Copy link

That is due to the problem within the package 'lightning' or 'pytorch-lightning'.
Please keep their versions the same with those in environment_strict.yaml.

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

No branches or pull requests

6 participants