报错解决MaxRetryError(“HTTPSConnectionPool(host=‘huggingface.co‘, port=443):xxx“)

这篇具有很好参考价值的文章主要介绍了报错解决MaxRetryError(“HTTPSConnectionPool(host=‘huggingface.co‘, port=443):xxx“)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

完整的错误信息

'(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /bert-base-uncased/resolve/main/vocab.txt (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f1320354880>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 625af900-631f-4614-9358-30364ecacefe)')' thrown while requesting HEAD https://huggingface.co/bert-base-uncased/resolve/main/vocab.txt
'(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /bert-base-uncased/resolve/main/added_tokens.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f1320354d60>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 1679a995-7441-4afe-a685-9a7bd6da9f2a)')' thrown while requesting HEAD https://huggingface.co/bert-base-uncased/resolve/main/added_tokens.json
'(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /bert-base-uncased/resolve/main/special_tokens_map.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f13202fb250>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 9af5b73e-5230-45d7-8886-5d37d38f09a8)')' thrown while requesting HEAD https://huggingface.co/bert-base-uncased/resolve/main/special_tokens_map.json
'(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /bert-base-uncased/resolve/main/tokenizer_config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f13202fb730>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 12136040-d033-4099-821c-dcb80fb50018)')' thrown while requesting HEAD https://huggingface.co/bert-base-uncased/resolve/main/tokenizer_config.json
Traceback (most recent call last):
  File "/tmp/pycharm_project_494/Zilean-Classifier/main.py", line 48, in <module>
    tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
  File "/root/miniconda3/envs/DL/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1838, in from_pretrained
    raise EnvironmentError(
OSError: Can't load tokenizer for 'bert-base-uncased'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'bert-base-uncased' is the correct path to a directory containing all relevant files for a BertTokenizer tokenizer.

首先造成这种错误的原因主要是因为你的服务器没有办法连接huggingface的原因,你可以直接在你的服务器上尝试能否直接ping

ping huggingface.co

那我的机器就是没有数据传输过来,当然前提是你自己的服务器一定要有网络连接(可以尝试ping www.baidu.com来检测自己机器是否有网络)。

解决方案1

使用VPN,这个方法比较适用机器是你自己的,如果机器不是你的,你搭VPN比较麻烦,因为租的服务器会定时清理,在Linux搭建VPN也很简单,大家搜索一哈有很多方案

解决方案2【推荐】

第二种方式适用于租赁的机器的情况,就是直接将本地的下载好(你的本地也需要能访问外网)的预训练模型上传上去,如果你已经在你的本地简单跑过代码了,没有就去官网下载,首先我们确定我们本地文件所处的路径【windows下应该在你的用户文件下面又有个.cache,注意打开隐藏文件夹】:

  • 将指定的模型下载到本地【本地机器需要科学上网】

    from transformers import BertModel, BertTokenizer
    
    # 使用bert-large-uncased
    model = BertModel.from_pretrained('bert-large-uncased')
    tokenizer = BertTokenizer.from_pretrained('bert-large-uncased')
    

    此时你的机器上会出现如下图片:
    报错解决MaxRetryError(“HTTPSConnectionPool(host=‘huggingface.co‘, port=443):xxx“),服务器,linux

  • 找到本地下载好的模型文件

    • 如果你是windows用户,你的用户User文件下面又有个.cache/huggingface/hub/,注意打开隐藏文件
    • 如果你是macos用户在下面地址中
      ~/.cache/huggingface/hub/models--bert-base-uncased
      
  • 上传文件到服务器上
    将本地文件上传到服务器的下面地址中

    ~/.cache/huggingface/hub/models--bert-base-uncased
    

    就可以运行你的代码了,但是这里运行的时候有个小问题,就是你运行时候仍然会报错说无法下载这些文件,请耐心等待,你的代码会正常运行
    报错解决MaxRetryError(“HTTPSConnectionPool(host=‘huggingface.co‘, port=443):xxx“),服务器,linux

    如果你不想出现之前上面还显示出错的问题,那么修改之前的加载方法,之前的加载方法为:

    config = BertConfig.from_pretrained(model_name) 
    

    修改为

    # 指定本地bert模型路径
    bert_model_dir = "/path/to/bert/model" 
    
    config = transformers.BertConfig.from_pretrained(bert_model_dir)
    

    即可文章来源地址https://www.toymoban.com/news/detail-716341.html

到了这里,关于报错解决MaxRetryError(“HTTPSConnectionPool(host=‘huggingface.co‘, port=443):xxx“)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • OpenAI调用API报错 time out:HTTPSConnectionPool(host=‘api.openai.com‘, port=443)

    代码如下(源自网络): 执行报错: 参考大佬文章:传送门 简单来说就是 1.26.0 版本的urllib3添加了HTTPS支持,但代理服务器不支持HTTPS,所以报错(pip走代理报错也差不多类似原因,具体请参考上文,有详细解读) 这个方法对部分人有用,但很不幸我是另一部分(哭)! 查

    2024年02月06日
    浏览(45)
  • pip安装模块报错ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org‘, port=443): Read timed

    今天在安装python模块时提示 ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out 具体报错如下: 处理方法 pip --default-timeout=100 install -U pygame 这使用pip安装超时,绝大多数原因是pip源在外国,所以国内使用,网络就算稳定,也有一定超时。–default-timeo

    2024年02月11日
    浏览(32)
  • 报错解决:urllib3.exceptions.MaxRetryError

    今天使用requests异步加载抓取数据的时候报错: urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=\\\'127.0.0.1\\\', port=6723):  Max retries exceeded with url:  /wd/hub/session (Caused by NewConnectionError (\\\'urllib3.connection.HTTPConnection object at 0x0000000003517D68: Failed to establish a new connection: [WinError 10061] 由于目标计

    2024年02月15日
    浏览(31)
  • 下载torchvision报错:Could not install packages due to an OSError: HTTPSConnectionPool(host=‘files.python

    报错如下:Could not install packages due to an OSError: HTTPSConnectionPool(host=\\\'files.pythonhosted.org\\\', port=443): Max retries exceeded with url: /packages/c0/8f/dfa473f3a6241bff91ae8bb90 5bd0afceb827f37de2917a94b5c4b1112bf/Pillow-9.3.0-cp39-cp39-win_amd64.whl (Caused by ConnectTimeoutError(pip._vendor.urllib3.connection.HTTPSConnection object at 0x000

    2024年02月15日
    浏览(34)
  • huggingface.co下载模型

    1、在测试clip-interrogator 发现BLIP CLIP模型需要离线加载,以下手工下载并指定路径。 并运行TRANSFORMERS_OFFLINE=1 python run.py, run.py如下 其他huggingface的模型处理方法可参考。 2、BLIP模型 根据Readme指引下载,存,指定路径即可。 BLIP//pretrained/model_base_caption_capfilt_large.pth  BLIP//pretrai

    2024年02月04日
    浏览(37)
  • 解决requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘api.github.com‘, port=443): Max retries

    一般来说,出现这种错误的原因可能是以下之一: 代理设置错误 : 你的计算机或网络环境可能配置了代理服务器,但代理服务器设置可能不正确。你需要检查你的代理设置是否正确,并确保它们与你的网络环境相匹配。 代理服务器不可用 : 如果代理服务器无法访问或不可用

    2024年02月05日
    浏览(43)
  • 解决.ReadTimeoutError: HTTPSConnectionPool(host=‘pypi.tuna.tsinghua.edu.cn‘, port=443): Read timed o

    目录 解决.ReadTimeoutError: HTTPSConnectionPool(host=\\\'pypi.tuna.tsinghua.edu.cn\\\', port=443): Read timed out 方法1:增加超时时间 方法2:更换pip源 方法3:使用国内镜像加速器 在Python开发中,我们经常使用第三方库来满足各种需求。当我们使用pip安装这些库时,有时可能会遇到一些网络问题,特别

    2024年02月04日
    浏览(54)
  • 解决:requests.exceptions.SSLError: HTTPSConnectionPool(host=‘x‘,port=x): Max retries exceeded with url

    在使用selenium操作Chrome浏览器报错:requests.exceptions.SSLError: HTTPSConnectionPool(host=‘lv-pc-api-sinfonlineb.ulikecam.com’, port=443): Max retries exceeded with url: /get (Caused by SSLError(SSLError(1, ‘[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123)’))) 报错信息如下: 报错截图如下: 主要报错信息内容

    2024年02月21日
    浏览(30)
  • linux git clone出现OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to huggingface.co:443解决方案

      大家好,我是爱编程的喵喵。双985硕士毕业,现担任全栈工程师一职,热衷于将数据思维应用到工作与生活中。从事机器学习以及相关的前后端开发工作。曾在阿里云、科大讯飞、CCF等比赛获得多次Top名次。现为CSDN博客专家、人工智能领域优质创作者。喜欢通过博客创作

    2024年02月08日
    浏览(52)
  • 已解决ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host=‘files.pyt

    已解决ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443) ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443) 对于\\\"Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host=‘files.p

    2024年02月06日
    浏览(48)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包