当前位置:   article > 正文

在torch.hub加载bert-base-chinese模型的时候出错rate limit exceeded_urllib.error.httperror: http error 403: rate limit

urllib.error.httperror: http error 403: rate limit exceeded

参考:https://github.com/pytorch/vision/issues/4156

一、问题1:rate limit exceeded

问题的产生代码

model = torch.hub.load('huggingface/pytorch-transformers', 'model', 'bert-base-chinese')

环境

pytorch 1.9.0

torchvision 0.10.0

问题

urllib.error.HTTPError: HTTP Error 403: rate limit exceeded

解决办法:

以下方法是可以尝试的方法

1. 更改torch版本

更改torch版本从1.9.0+cpu转到1.7.0

2. 注释错误代码行

注释掉hub.py的162行的方法

    _validate_not_a_forked_repo

3. 在加载错误代码之前添加代码:

    torch.hub._validate_not_a_forked_repo=lambda a,b,c: True

4. 设置github的token来增加api访问次数

        应该没用,因为【torch.hub.load】我们访问的是:https://github.com/...。而不是https://api.github.com/  

如果需要改变可以参考:

https://blog.csdn.net/caroline_wendy/article/details/109337216

如何增加GitHub api的访问次数(从每小时60到每小时5000)

如何让github中API的请求达到5000次

二、问题2:URLError

如果再次运行代码,报错:

我将torch的版本从1.9.0变成了1.8.1,但是报错:

 Downloading: "https://github.com/huggingface/pytorch-transformers/archive/master.zip" to /root/.cache/torch/hub/master.zip
    urllib.error.URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:841)>

原因:请求github.com请求超时

解决:

windows或Ubuntu中请求github.com请求超时,或在下载GitHub文件出现:<urlopen error [Errno 110] Connection timed out>

三、问题3:Missing dependencies

新的错误:

RuntimeError: Missing dependencies: sentencepiece

这个时候已经下载下来了

原因:请求github.com请求超时

解决:

 pip install --user transformers

 pip install --user sentencepiece

如果安装出错,请参考:Python - 安装sentencepiece异常

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/342935
推荐阅读
相关标签
  

闽ICP备14008679号