运行python cli_demo.py报错 #879
Replies: 3 comments 2 replies
-
用绝对路径试试 |
Beta Was this translation helpful? Give feedback.
-
我也是。我尝试将cli_demo.py和模型放到同一个目录下,并将MODEL_PATH改成'./chatglm3-6b'后错误依旧。然后有将chatglm3-6b目录下的toneinzer_config.json中 |
Beta Was this translation helpful? Give feedback.
-
刚刚在huggingface上看到解决方案 “try to change "THUDM/chatglm3-6b--tokenization_chatglm.ChatGLMTokenizer" to "tokenization_chatglm.ChatGLMTokenizer”。 试过了,可行。 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
已经将MODEL_PATH = os.environ.get('MODEL_PATH', '../chatglm3-6b')这行代码进行修改,但无法导入ChatGML,报错中需要存放在chatglm3中的tokenization_chatglm.py包已经在指定位置下载好了。请求一些指点,感谢。
以下是chatglm3-6b文件路径

随后是linux的报错:
(chatglm3) XXX@YY:~/ChatGLM/ChatGLM3/basic_demo$ python cli_demo.py
../chatglm3-6b ../chatglm3-6b
Could not locate the tokenization_chatglm.py inside THUDM/chatglm3-6b.
Traceback (most recent call last):
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connection.py", line 203, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
TimeoutError: timed out
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connectionpool.py", line 790, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connectionpool.py", line 491, in _make_request
raise new_e
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
self._validate_conn(conn)
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1096, in _validate_conn
conn.connect()
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connection.py", line 611, in connect
self.sock = sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connection.py", line 212, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f5b53f51450>, 'Connection to huggingface.co timed out. (connect timeout=10)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/connectionpool.py", line 844, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/urllib3/util/retry.py", line 515, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /THUDM/chatglm3-6b/resolve/main/tokenization_chatglm.py (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f5b53f51450>, 'Connection to huggingface.co timed out. (connect timeout=10)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1238, in hf_hub_download
metadata = get_hf_file_metadata(
^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1631, in get_hf_file_metadata
r = _request_wrapper(
^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 385, in _request_wrapper
response = _request_wrapper(
^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 408, in _request_wrapper
response = get_session().request(method=method, url=url, **params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/utils/_http.py", line 67, in send
return super().send(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/requests/adapters.py", line 507, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /THUDM/chatglm3-6b/resolve/main/tokenization_chatglm.py (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f5b53f51450>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: ca420ae5-6387-4f4a-a693-47b0412d6892)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/transformers/utils/hub.py", line 398, in cached_file
resolved_file = hf_hub_download(
^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/huggingface_hub/file_download.py", line 1371, in hf_hub_download
raise LocalEntryNotFoundError(
huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/XXX/ChatGLM/ChatGLM3/basic_demo/cli_demo.py", line 9, in
tokenizer = AutoTokenizer.from_pretrained(TOKENIZER_PATH, trust_remote_code=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/transformers/models/auto/tokenization_auto.py", line 806, in from_pretrained
tokenizer_class = get_class_from_dynamic_module(class_ref, pretrained_model_name_or_path, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/transformers/dynamic_module_utils.py", line 488, in get_class_from_dynamic_module
final_module = get_cached_module_file(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/transformers/dynamic_module_utils.py", line 293, in get_cached_module_file
resolved_module_file = cached_file(
^^^^^^^^^^^^
File "/home/XXX/anaconda3/envs/chatglm3/lib/python3.11/site-packages/transformers/utils/hub.py", line 441, in cached_file
raise EnvironmentError(
OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like THUDM/chatglm3-6b is not the path to a directory containing a file named tokenization_chatglm.py.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
Beta Was this translation helpful? Give feedback.
All reactions