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

TypeError: __init__() got an unexpected keyword argument 'device' #55

Open
zyj-2000 opened this issue May 11, 2023 · 7 comments
Open

TypeError: __init__() got an unexpected keyword argument 'device' #55

zyj-2000 opened this issue May 11, 2023 · 7 comments

Comments

@zyj-2000
Copy link

TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 xm = load_model('transmitter', device=device)
2 model = load_model('text300M', device=device)
3 diffusion = diffusion_from_config(load_config('diffusion'))

File ~/Projects/shap-e/shap_e/models/download.py:146, in load_model(model_name, device, **kwargs)
139 def load_model(
140 model_name: str,
141 device: torch.device,
142 **kwargs,
143 ) -> Dict[str, torch.Tensor]:
144 from .configs import model_from_config
--> 146 model = model_from_config(load_config(model_name, **kwargs), device=device)
147 model.load_state_dict(load_checkpoint(model_name, device=device, **kwargs))
148 model.eval()

File ~/Projects/shap-e/shap_e/models/configs.py:59, in model_from_config(config, device)
56 return MultiviewTransformerEncoder(device=device, dtype=torch.float32, **config)
57 elif name == "Transmitter":
58 # device = torch.device('cuda')
---> 59 renderer = model_from_config(config.pop("renderer"), device=device)
60 param_shapes = {
61 k: v.shape[1:] for k, v in batch_meta_state_dict(renderer, batch_size=1).items()
...
97 )
99 mlp_init(self.mlp, init=init, init_scale=init_scale)
101 self.activation = get_act(activation)

TypeError: init() got an unexpected keyword argument 'device'

@jayanthd26
Copy link

TypeError Traceback (most recent call last) Cell In[3], line 1 ----> 1 xm = load_model('transmitter', device=device) 2 model = load_model('text300M', device=device) 3 diffusion = diffusion_from_config(load_config('diffusion'))

File ~/Projects/shap-e/shap_e/models/download.py:146, in load_model(model_name, device, **kwargs) 139 def load_model( 140 model_name: str, 141 device: torch.device, 142 **kwargs, 143 ) -> Dict[str, torch.Tensor]: 144 from .configs import model_from_config --> 146 model = model_from_config(load_config(model_name, **kwargs), device=device) 147 model.load_state_dict(load_checkpoint(model_name, device=device, **kwargs)) 148 model.eval()

File ~/Projects/shap-e/shap_e/models/configs.py:59, in model_from_config(config, device) 56 return MultiviewTransformerEncoder(device=device, dtype=torch.float32, **config) 57 elif name == "Transmitter": 58 # device = torch.device('cuda') ---> 59 renderer = model_from_config(config.pop("renderer"), device=device) 60 param_shapes = { 61 k: v.shape[1:] for k, v in batch_meta_state_dict(renderer, batch_size=1).items() ... 97 ) 99 mlp_init(self.mlp, init=init, init_scale=init_scale) 101 self.activation = get_act(activation)

TypeError: init() got an unexpected keyword argument 'device'

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
add this in line 1

@zyj-2000
Copy link
Author

zyj-2000 commented May 11, 2023

@jayanthd26
Thanks for your fast reply! However, I encountered with the error when I was running the "sample_text_to_3d.ipynb", which has added the code "device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')" in line 8, before the function "load_model". I think it may have other ways to fix it?

@unixpickle
Copy link
Collaborator

Wha version of pytorch are you running with? Try upgrading.

@zyj-2000
Copy link
Author

@unixpickle
Thanks for your reply. I used pytorch 1.8+cu113 in Ubuntu18.04. I will try to update it and reply to you.

@ALLIZZWELL123
Copy link

@unixpickle Thanks for your reply. I used pytorch 1.8+cu113 in Ubuntu18.04. I will try to update it and reply to you.

bro,have you sloved this problem,how?

@zyj-2000
Copy link
Author

zyj-2000 commented Aug 3, 2023

@ALLIZZWELL123 Sorry, for some reason, I haven't tried the update yet. I will try as soon as possible. On the other hand, welcome to solve the problem jointly! Thanks!

@zyj-2000
Copy link
Author

zyj-2000 commented Aug 4, 2023

I have successfully get the mesh and ply result. I install all the requirements follow the setup.py by the command
pip install -e .
then everything is ok. The torch I use now is torch 2.0.1.
YRJAWJP$L_LPL$@@$F(EMI

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

4 participants