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

运行时有个错误,请问如何解决? #1

Open
ArcherPrim opened this issue Feb 15, 2023 · 13 comments
Open

运行时有个错误,请问如何解决? #1

ArcherPrim opened this issue Feb 15, 2023 · 13 comments

Comments

@ArcherPrim
Copy link

您好,我运行predict.py时发生报错,请问一下如何解决呢?AttributeError: module 'torch.utils.data' has no attribute 'BatchSamplerDistributedSamplerDataset'

@caip1299920300
Copy link
Owner

predict.py脚本没有调用torch.utils.data这个函数库的东西,所以可能是pytorch版本问题,给你个排除思路:

@caip1299920300
Copy link
Owner

运行utils/dataloader.py文件,报错的话,可能就是这个脚本里的那个torch.utils.dataxx 导入需要修改。不过'BatchSamplerDistributedSamplerDataset'这个应该是自定义的数据导入类,也许你运行的predict.py不是Yolov3_LPRnet_pytorch这个项目里面的

@ArcherPrim
Copy link
Author

谢谢您,我运行predict.py的时候是在项目里运行的,我看了一下我pytorch版本是1.71,但是不是1.71+cu101,我现在安装1.7.1+cu101试试

@caip1299920300
Copy link
Owner

那pytorch应该不会有问题,不用重装,你运行utils/dataloader.py文件试试,这个没问题就不是环境的问题

@ArcherPrim
Copy link
Author

运行utils/dataloader.py,显示报错 ModuleNotFoundError: No module named 'utils.utils'; 'utils' is not a package

@caip1299920300
Copy link
Owner

from torch.utils.data.dataset import Dataset,只保留这句,其他注释掉,没问题的话,重启一下重新打开这个项目,再运行,这样成功率51%

@ArcherPrim
Copy link
Author

在utils/dataloader.py中,只保留from torch.utils.data.dataset import Datase,运行utils/dataloader.py,没有报错;

再次运行predict.py时,还是报错AttributeError: module 'torch.utils.data' has no attribute 'BatchSamplerDistributedSamplerDataset'

@caip1299920300
Copy link
Owner

“BatchSamplerDistributedSamplerDataset”这个东西,你搜索一下项目里看看有没有把。可能那里无意中加上了

@ArcherPrim
Copy link
Author

试了一下全局搜索 BatchSamplerDistributedSamplerDataset ,没有搜到,全局代码里没有BatchSamplerDistributedSamplerDataset,┭┮﹏┭┮

@caip1299920300
Copy link
Owner

那什么问题都没有,重新电脑把,重开项目[捂脸]

@ArcherPrim
Copy link
Author

啊哈哈,好嘞

@ArcherPrim
Copy link
Author

谢谢您嗷

@caip1299920300
Copy link
Owner

不客气

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