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: module 'torch.hub' has no attribute 'get_dir' #22

Open
ylxbyy opened this issue Aug 31, 2021 · 6 comments
Open

AttributeError: module 'torch.hub' has no attribute 'get_dir' #22

ylxbyy opened this issue Aug 31, 2021 · 6 comments

Comments

@ylxbyy
Copy link

ylxbyy commented Aug 31, 2021

Hello~

Thanks for the nice work.

When I use the 'hawp/src/predict.py' code to predict new images, I met the following error. I checked the attributes in torch.hub, seeing that 'get_dir' does not exist and there are some other similar attributes e.g. 'set_dir()', 'hub_dir'. I have tried other attributes but still failed in loading the pretrained model.

File "/home/yyz/hawp/parsing/detector.py", line 430, in get_hawp_model
hubdir = torch.hub.get_dir()
AttributeError: module 'torch.hub' has no attribute 'get_dir'

Could you please give me some suggestions in dealing with the problem?

@cherubicXN
Copy link
Owner

I think this is because of the version. What is your version of pytorch?

@ylxbyy
Copy link
Author

ylxbyy commented Aug 31, 2021

I think this is because of the version. What is your version of pytorch?

Pytorch 1.4.0, torchvision 0.5.0, cuda 10.0, python 3.6

@cherubicXN
Copy link
Owner

After checking the official documents between 1.4.0 and 1.8.1, I found that torch.hub.hub_dir() was changed to torch.hub.get_dir()

@ylxbyy
Copy link
Author

ylxbyy commented Aug 31, 2021

After checking the official documents between 1.4.0 and 1.8.1, I found that torch.hub.hub_dir() was changed to torch.hub.get_dir()

I tried torch.hub.hub_dir() in the version 1.4.0, but error occurred (TypeError: 'str' object is not callable). Then I tried set_dir() and hub_dir together and it worked.

torch.hub.set_dir('dir')
hubdir = torch.hub.hub_dir

However, another error occured, as the following shows.

File "/home/yyz/anaconda3/envs/hawp/lib/python3.6/site-packages/torch/hub.py", line 501, in load_state_dict_from_url
raise RuntimeError('Only one file(not dir) is allowed in the zipfile')
RuntimeError: Only one file(not dir) is allowed in the zipfile

It seems that the error is also related to the pytorch version. But, the version 1.8.1 cannot be installed when cuda version is 10.0. May I ask which version of cuda and which version of pytorch are used in the code? Shall I change my cuda version to 10.1?

@cherubicXN
Copy link
Owner

cherubicXN commented Aug 31, 2021 via email

@ylxbyy
Copy link
Author

ylxbyy commented Sep 6, 2021

Let me fix the bug tomorrow ylxbyy @.***>于2021年8月31日 周二下午10:10写道:

Thank you for your help.

I didn't solve the 'RuntimeError: Only one file(not dir) is allowed in the zipfile' error in my previous environment. Finally, I changed my environment to: python 3.7, cuda 10.1, pytorch 1.8.1, and successfully predicted images with the original codes.

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

2 participants