AttributeError: module ‘torch.library’ has no attribute ‘register_fake’
AttributeError: partially initialized module ‘torchvision’ has no attribute ‘extension’ (most likely due to a circular import)
RemoteDisconnected: Remote end closed connection without response
model = torch.hub.load('pytorch/vision', 'resnet50', pretrained=True).to(device)
(前提条件是确认自己的torch,torchvision版本对应正确哦)
调用torch.hub.load时出现这些错误,有1. 重装torch的方法,还有2. 换conda环境的方法
- 有很大概率不行;
- 应该可以,但是对于我工作量太大。
我采用了之前更常用的模型调用方法,
from torchvision.models import resnet50, ResNet50_Weights
weights = ResNet50_Weights.DEFAULT
model = resnet50(weights=weights).to(device)
解决了上述问题。
有意思的是,这时候再次调用有问题的语句,也可以正常运行了。