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

ModelScope urllib.error.URLError: <urlopen error [Errno 104] Connection reset by peer> #23

Closed
vansin opened this issue Oct 10, 2023 · 1 comment

Comments

@vansin
Copy link
Contributor

vansin commented Oct 10, 2023

import torch
from modelscope import snapshot_download, AutoModel, AutoTokenizer

torch.set_grad_enabled(False)

# init model and tokenizer
model_dir = snapshot_download('Shanghai_AI_Laboratory/internlm-xcomposer-7b')
model = AutoModel.from_pretrained(model_dir, trust_remote_code=True).cuda().eval()
root@autodl-container-9e2911833c-01d8deff:~/autodl-tmp# python download.py 
2023-10-10 21:52:08,079 - modelscope - INFO - PyTorch version 1.11.0+cu113 Found.
2023-10-10 21:52:08,081 - modelscope - INFO - Loading ast index from /root/.cache/modelscope/ast_indexer
2023-10-10 21:52:08,119 - modelscope - INFO - Loading done! Current index file version is 1.9.2, with md5 1c9bf186d1e03088e5abfbd8664a1def and a total number of 941 components indexed
2023-10-10 21:52:08,686 - modelscope - WARNING - There is no version specified and there is no version in the model repository,use the master branch, which is fragile, please use it with caution!
2023-10-10 21:52:08,686 - modelscope - INFO - Model revision not specified, use revision: master
Init VIT ... Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.8/urllib/request.py", line 1354, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/root/miniconda3/lib/python3.8/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/root/miniconda3/lib/python3.8/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/root/miniconda3/lib/python3.8/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/root/miniconda3/lib/python3.8/http/client.py", line 1007, in _send_output
    self.send(msg)
  File "/root/miniconda3/lib/python3.8/http/client.py", line 947, in send
    self.connect()
  File "/root/miniconda3/lib/python3.8/http/client.py", line 1421, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/root/miniconda3/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/root/miniconda3/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/root/miniconda3/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "download.py", line 8, in <module>
    model = AutoModel.from_pretrained(model_dir, trust_remote_code=True).cuda().eval()
  File "/root/miniconda3/lib/python3.8/site-packages/modelscope/utils/hf_util.py", line 181, in from_pretrained
    module_obj = module_class.from_pretrained(model_dir, *model_args,
  File "/root/miniconda3/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py", line 560, in from_pretrained
    return model_class.from_pretrained(
  File "/root/miniconda3/lib/python3.8/site-packages/modelscope/utils/hf_util.py", line 78, in from_pretrained
    return ori_from_pretrained(cls, model_dir, *model_args, **kwargs)
  File "/root/miniconda3/lib/python3.8/site-packages/transformers/modeling_utils.py", line 3085, in from_pretrained
    model = cls(config, *model_args, **model_kwargs)
  File "/root/.cache/huggingface/modules/transformers_modules/internlm-xcomposer-7b/modeling_InternLM_XComposer.py", line 43, in __init__
    self.visual_encoder = create_eva_vit_g()
  File "/root/.cache/huggingface/modules/transformers_modules/internlm-xcomposer-7b/modeling_vit.py", line 522, in create_eva_vit_g
    cached_file = download_cached_file(url, check_hash=False, progress=True)
  File "/root/.cache/huggingface/modules/transformers_modules/internlm-xcomposer-7b/modeling_utils.py", line 44, in download_cached_file
    timm_hub.download_cached_file(url, check_hash, progress)
  File "/root/miniconda3/lib/python3.8/site-packages/timm/models/_hub.py", line 85, in download_cached_file
    download_url_to_file(url, cached_file, hash_prefix, progress=progress)
  File "/root/miniconda3/lib/python3.8/site-packages/torch/hub.py", line 457, in download_url_to_file
    u = urlopen(req)
  File "/root/miniconda3/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/root/miniconda3/lib/python3.8/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/root/miniconda3/lib/python3.8/urllib/request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/root/miniconda3/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/root/miniconda3/lib/python3.8/urllib/request.py", line 1397, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/root/miniconda3/lib/python3.8/urllib/request.py", line 1357, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 104] Connection reset by peer>
root@autodl-container-9e2911833c-01d8deff:~/autodl-tmp# 
@myownskyW7
Copy link
Collaborator

我们已经在huggingface和modelscope里面的代码修复了这个bug,可以清理掉旧的下载内容,重新尝试下

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