OpenMOSS / MOSS

An open-source tool-augmented conversational language model from Fudan University
https://txsun1997.github.io/blogs/moss.html
Apache License 2.0
11.92k stars 1.14k forks source link

网络连接错误 #204

Closed Julong-Zheng closed 1 year ago

Julong-Zheng commented 1 year ago

执行下面这句话报错,怎么解决? model = AutoModelForCausalLM.from_pretrained("fnlp/moss-moon-003-sft-int4", trust_remote_code=True).half().cuda(device='1,2,3')

错误如下 File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/connectionpool.py:449, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 445 except BaseException as e: 446 # Remove the TypeError from the exception chain in 447 # Python 3 (including for exceptions like SystemExit). 448 # Otherwise it looks like a bug in the code. --> 449 six.raise_from(e, None) 450 except (SocketTimeout, BaseSSLError, SocketError) as e:

File :3, in raise_from(value, from_value)

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/connectionpool.py:444, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 443 try: --> 444 httplib_response = conn.getresponse() 445 except BaseException as e: 446 # Remove the TypeError from the exception chain in 447 # Python 3 (including for exceptions like SystemExit). 448 # Otherwise it looks like a bug in the code.

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/http/client.py:1348, in HTTPConnection.getresponse(self) 1347 try: -> 1348 response.begin() 1349 except ConnectionError:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/http/client.py:316, in HTTPResponse.begin(self) 315 while True: --> 316 version, status, reason = self._read_status() 317 if status != CONTINUE:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/http/client.py:277, in HTTPResponse._read_status(self) 276 def _read_status(self): --> 277 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") 278 if len(line) > _MAXLINE:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/socket.py:669, in SocketIO.readinto(self, b) 668 try: --> 669 return self._sock.recv_into(b) 670 except timeout:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/ssl.py:1241, in SSLSocket.recv_into(self, buffer, nbytes, flags) 1238 raise ValueError( 1239 "non-zero flags not allowed in calls to recv_into() on %s" % 1240 self.class) -> 1241 return self.read(nbytes, buffer) 1242 else:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/ssl.py:1099, in SSLSocket.read(self, len, buffer) 1098 if buffer is not None: -> 1099 return self._sslobj.read(len, buffer) 1100 else:

timeout: The read operation timed out

During handling of the above exception, another exception occurred:

ReadTimeoutError Traceback (most recent call last) File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/requests/adapters.py:487, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies) 486 try: --> 487 resp = conn.urlopen( 488 method=request.method, 489 url=url, 490 body=request.body, 491 headers=request.headers, 492 redirect=False, 493 assert_same_host=False, 494 preload_content=False, 495 decode_content=False, 496 retries=self.max_retries, 497 timeout=timeout, 498 chunked=chunked, 499 ) 501 except (ProtocolError, OSError) as err:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/connectionpool.py:787, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 785 e = ProtocolError("Connection aborted.", e) --> 787 retries = retries.increment( 788 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] 789 ) 790 retries.sleep()

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/util/retry.py:550, in Retry.increment(self, method, url, response, error, _pool, _stacktrace) 549 if read is False or not self._is_method_retryable(method): --> 550 raise six.reraise(type(error), error, _stacktrace) 551 elif read is not None:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/packages/six.py:770, in reraise(tp, value, tb) 769 raise value.with_traceback(tb) --> 770 raise value 771 finally:

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/connectionpool.py:703, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw) 702 # Make the request on the httplib connection object. --> 703 httplib_response = self._make_request( 704 conn, 705 method, 706 url, 707 timeout=timeout_obj, 708 body=body, 709 headers=headers, 710 chunked=chunked, 711 ) 713 # If we're going to release the connection in finally:, then 714 # the response doesn't need to know about the connection. Otherwise 715 # it will also try to release it and we'll have a double-release 716 # mess.

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/connectionpool.py:451, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw) 450 except (SocketTimeout, BaseSSLError, SocketError) as e: --> 451 self._raise_timeout(err=e, url=url, timeout_value=read_timeout) 452 raise

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/urllib3/connectionpool.py:340, in HTTPConnectionPool._raise_timeout(self, err, url, timeout_value) 339 if isinstance(err, SocketTimeout): --> 340 raise ReadTimeoutError( 341 self, url, "Read timed out. (read timeout=%s)" % timeout_value 342 ) 344 # See the above comment about EAGAIN in Python 3. In Python 2 we have 345 # to specifically catch it and throw the timeout error

ReadTimeoutError: HTTPSConnectionPool(host='cdn-lfs.huggingface.co', port=443): Read timed out. (read timeout=10.0)

During handling of the above exception, another exception occurred:

ReadTimeout Traceback (most recent call last) Cell In[11], line 1 ----> 1 model = AutoModelForCausalLM.from_pretrained("fnlp/moss-moon-003-sft-int4", trust_remote_code=True).half().cuda(device='1,2,3')

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py:458, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, kwargs) 454 module_file, class_name = class_ref.split(".") 455 model_class = get_class_from_dynamic_module( 456 pretrained_model_name_or_path, module_file + ".py", class_name, hub_kwargs, *kwargs 457 ) --> 458 return model_class.from_pretrained( 459 pretrained_model_name_or_path, model_args, config=config, hub_kwargs, kwargs 460 ) 461 elif type(config) in cls._model_mapping.keys(): 462 model_class = _get_model_class(config, cls._model_mapping)

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/transformers/modeling_utils.py:2137, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, *model_args, kwargs) 2122 try: 2123 # Load from URL or cache if already cached 2124 cached_file_kwargs = dict( 2125 cache_dir=cache_dir, 2126 force_download=force_download, (...) 2135 _commit_hash=commit_hash, 2136 ) -> 2137 resolved_archive_file = cached_file(pretrained_model_name_or_path, filename, cached_file_kwargs) 2139 # Since we set _raise_exceptions_for_missing_entries=False, we don't get an exception but a None 2140 # result when internet is up, the repo and revision exist, but the file does not. 2141 if resolved_archive_file is None and filename == SAFE_WEIGHTS_NAME: 2142 # Maybe the checkpoint is sharded, we try to grab the index name in this case.

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/transformers/utils/hub.py:409, in cached_file(path_or_repo_id, filename, cache_dir, force_download, resume_download, proxies, use_auth_token, revision, local_files_only, subfolder, user_agent, _raise_exceptions_for_missing_entries, _raise_exceptions_for_connection_errors, _commit_hash) 406 user_agent = http_user_agent(user_agent) 407 try: 408 # Load from URL or cache if already cached --> 409 resolved_file = hf_hub_download( 410 path_or_repo_id, 411 filename, 412 subfolder=None if len(subfolder) == 0 else subfolder, 413 revision=revision, 414 cache_dir=cache_dir, 415 user_agent=user_agent, 416 force_download=force_download, 417 proxies=proxies, 418 resume_download=resume_download, 419 use_auth_token=use_auth_token, 420 local_files_only=local_files_only, 421 ) 423 except RepositoryNotFoundError: 424 raise EnvironmentError( 425 f"{path_or_repo_id} is not a local folder and is not a valid model identifier " 426 "listed on 'https://huggingface.co/models'\nIf this is a private repository, make sure to " 427 "pass a token having permission to this repo with use_auth_token or log in with " 428 "huggingface-cli login and pass use_auth_token=True." 429 )

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:120, in validate_hf_hub_args.._inner_fn(*args, *kwargs) 117 if check_use_auth_token: 118 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs) --> 120 return fn(args, **kwargs)

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/huggingface_hub/file_download.py:1364, in hf_hub_download(repo_id, filename, subfolder, repo_type, revision, library_name, library_version, cache_dir, local_dir, local_dir_use_symlinks, user_agent, force_download, force_filename, proxies, etag_timeout, resume_download, token, local_files_only, legacy_cache_layout) 1361 with temp_file_manager() as temp_file: 1362 logger.info("downloading %s to %s", url, temp_file.name) -> 1364 http_get( 1365 url_to_download, 1366 temp_file, 1367 proxies=proxies, 1368 resume_size=resume_size, 1369 headers=headers, 1370 expected_size=expected_size, 1371 ) 1373 if local_dir is None: 1374 logger.info(f"Storing {url} in cache at {blob_path}")

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/huggingface_hub/file_download.py:505, in http_get(url, temp_file, proxies, resume_size, headers, timeout, max_retries, expected_size) 502 if resume_size > 0: 503 headers["Range"] = "bytes=%d-" % (resume_size,) --> 505 r = _request_wrapper( 506 method="GET", 507 url=url, 508 stream=True, 509 proxies=proxies, 510 headers=headers, 511 timeout=timeout, 512 max_retries=max_retries, 513 ) 514 hf_raise_for_status(r) 515 content_length = r.headers.get("Content-Length")

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/huggingface_hub/file_download.py:442, in _request_wrapper(method, url, max_retries, base_wait_time, max_wait_time, timeout, follow_relative_redirects, params) 439 return response 441 # 3. Exponential backoff --> 442 return http_backoff( 443 method=method, 444 url=url, 445 max_retries=max_retries, 446 base_wait_time=base_wait_time, 447 max_wait_time=max_wait_time, 448 retry_on_exceptions=(ConnectTimeout, ProxyError), 449 retry_on_status_codes=(), 450 timeout=timeout, 451 params, 452 )

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/huggingface_hub/utils/_http.py:212, in http_backoff(method, url, max_retries, base_wait_time, max_wait_time, retry_on_exceptions, retry_on_status_codes, kwargs) 209 kwargs["data"].seek(io_obj_initial_pos) 211 # Perform request and return if status_code is not in the retry list. --> 212 response = session.request(method=method, url=url, kwargs) 213 if response.status_code not in retry_on_status_codes: 214 return response

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/requests/sessions.py:587, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) 582 send_kwargs = { 583 "timeout": timeout, 584 "allow_redirects": allow_redirects, 585 } 586 send_kwargs.update(settings) --> 587 resp = self.send(prep, **send_kwargs) 589 return resp

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/requests/sessions.py:701, in Session.send(self, request, kwargs) 698 start = preferred_clock() 700 # Send the request --> 701 r = adapter.send(request, kwargs) 703 # Total elapsed time of the request (approximately) 704 elapsed = preferred_clock() - start

File /home/data2/ZJL/anaconda3/envs/moss/lib/python3.8/site-packages/requests/adapters.py:533, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies) 531 raise SSLError(e, request=request) 532 elif isinstance(e, ReadTimeoutError): --> 533 raise ReadTimeout(e, request=request) 534 elif isinstance(e, _InvalidHeader): 535 raise InvalidHeader(e, request=request)

ReadTimeout: HTTPSConnectionPool(host='cdn-lfs.huggingface.co', port=443): Read timed out. (read timeout=10.0)

starplatinum3 commented 1 year ago

模型下载到本地 再指定路径

 mkdir -p /j05025/model/fnlp/moss-moon-003-sft
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/.gitattributes -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/LICENSE -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/README.md -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/added_tokens.json -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/config.json -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/configuration_moss.py -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/merges.txt -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/modeling_moss.py -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/pytorch_model-00001-of-00004.bin -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/pytorch_model-00002-of-00004.bin -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/pytorch_model-00003-of-00004.bin -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/pytorch_model-00004-of-00004.bin -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/pytorch_model.bin.index.json -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/special_tokens_map.json -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/tokenization_moss.py -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/tokenizer_config.json -c -P /j05025/model/fnlp/moss-moon-003-sft  &
wget https://huggingface.co/fnlp/moss-moon-003-sft/resolve/main/vocab.json -c -P /j05025/model/fnlp/moss-moon-003-sft  &