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: 'Graph' object has no attribute 'is_meta' #4

Open
anilakash opened this issue Oct 19, 2023 · 3 comments
Open

AttributeError: 'Graph' object has no attribute 'is_meta' #4

anilakash opened this issue Oct 19, 2023 · 3 comments

Comments

@anilakash
Copy link

Hi,
Thanks for sharing the codes for ANet. The ANet is trained and validated successfully but an error occurred in loading the checkpoint. Here are the details:

10:02:04 Load checkpoint from model_epoch_1.pth
Traceback (most recent call last):
File "/home/my_project_dir/script/run.py", line 62, in
train_and_validate(cfg, solver)
File "/home/my_project_dir/script/run.py", line 35, in train_and_validate
solver.load("model_epoch_%d.pth" % best_epoch)
File "/home/akash/anaconda3/envs/astarnet_conda/lib/python3.9/site-packages/torchdrug-0.2.1-py3.9.egg/torchdrug/core/engine.py", line 242, in load
self.model.load_state_dict(state["model"], strict=strict)
File "/home/akash/anaconda3/envs/astarnet_conda/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2138, in load_state_dict
load(self, state_dict)
File "/home/akash/anaconda3/envs/astarnet_conda/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2120, in load
module._load_from_state_dict(
File "/home/akash/anaconda3/envs/astarnet_conda/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2024, in _load_from_state_dict
if param.is_meta and not input_param.is_meta and not assign_to_params_buffers:
AttributeError: 'Graph' object has no attribute 'is_meta'

@KatarinaYuan
Copy link
Collaborator

KatarinaYuan commented Nov 9, 2023

Hi, we are so sorry for our late response.

Could you please provide the package version that you are currently using right now, especially for torch and torchdrug?

As I checked in Torch's commit history, there is at least no such constraint if param.is_meta and not input_param.is_meta and not assign_to_params_buffers: for torch==1.13.1 (which is the one I'm using right now).

The update for this constraint takes place in the following commit: pytorch/pytorch@ca7ece9

I guess it's worth a try to pass assign=True as torch suggested in the warning to bypass this constraint.

@benjaminnNgo
Copy link

Hi!
Does anyone know how to resolve this issue? I am using torch=2.3.0, torchdrug=0.2.1. I tried to set assign=True as @KatarinaYuan mentioned but it didn't help.

@benjaminnNgo
Copy link

benjaminnNgo commented Sep 25, 2024

I tried to print out all keys and values pairs of the model state dictionary and I found these:
"graph" : Graph(num_node=40943, num_edge=93003, num_relation=11, device='cuda:0')
"fact_graph": Graph(num_node=40943, num_edge=86835, num_relation=11, device='cuda:0').
I am not sure if they are registered as parameters or buffers of the model intentionally and must be kept in the model state. I am not sure if I could pop this out of the model state dictionary. @KatarinaYuan @KiddoZhu

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

3 participants