open-webui报错Connection to huggingface.co timed out.
总结:huggingface不能用,直接设置镜像:
HF_ENDPOINT=https://hf-mirror.com
缘起
随着大家纷纷复工,一些网站又恢复了以前不能用的状态,比如open-webui前几天还能用,现在就报错:
File "E:\py311\Lib\site-packages\urllib3\util\retry.py", line 519, 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: /api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000274C5F31590>, 'Connection to huggingface.co timed out. (connect timeout=None)'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\py311\Lib\site-packages\huggingface_hub\_snapshot_download.py", line 155, in snapshot_download
repo_info = api.repo_info(repo_id=repo_id, repo_type=repo_type, revision=revision, token=token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\huggingface_hub\hf_api.py", line 2704, in repo_info
return method(
^^^^^^^
File "E:\py311\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\huggingface_hub\hf_api.py", line 2488, in model_info
r = get_session().get(path, headers=headers, timeout=timeout, params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\requests\sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\huggingface_hub\utils\_http.py", line 93, in send
return super().send(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\requests\adapters.py", line 688, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/sentence-transformers/all-MiniLM-L6-v2/revision/main (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000274C5F31590>, 'Connection to huggingface.co timed out. (connect timeout=None)'))"), '(Request ID: 3f54bc76-7b85-4a85-ae98-0ecc3f5b2430)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "E:\py311\Lib\site-packages\open_webui\retrieval\utils.py", line 417, in get_model_path
model_repo_path = snapshot_download(**snapshot_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "E:\py311\Lib\site-packages\huggingface_hub\_snapshot_download.py", line 235, in snapshot_download
raise LocalEntryNotFoundError(
huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the specified revision on the local disk. Please check your internet connection and try again.
WARNI [sentence_transformers.SentenceTransformer] No sentence-transformers model found with name sentence-transformers/all-MiniLM-L6-v2. Creating a new one with mean pooling.
解决方法:
设置环境变量
Windows设置环境变量的方法
找到桌面的“我的电脑”图标,右键,选属性,选择“高级系统设置”,然后点击“环境变量”,就可以修改环境变量了。也可以通过开始菜单的“设置”-“系统”-“关于”--“高级系统设置”,找到“环境变量”设置按钮。
然后加入一个环境变量,名字:HF_ENDPOINT 内容:https://hf-mirror.com
重新开一个控制台终端,启动:
open-webui serve
v0.5.7 - building the best open-source AI user interface.
https://github.com/open-webui/open-webui
1_Pooling/config.json: 100%|██████████████████████████████████████████████████████████████████| 190/190 [00:00<?, ?B/s]
modules.json: 100%|███████████████████████████████████████████████████████████████████████████| 349/349 [00:00<?, ?B/s]
config_sentence_transformers.json: 100%|██████████████████████████████████████████████████████| 116/116 [00:00<?, ?B/s]
config.json: 612B [00:00, ?B/s]
.gitattributes: 1.23kB [00:00, ?B/s]
data_config.json: 39.3kB [00:00, ?B/s] | 0.00/199 [00:00<?, ?B/s]
README.md: 10.7kB [00:00, ?B/s] ?B/s]
Fetching 30 files: 0%| | 0/30 [00:04<?, ?it/s]
E:\py311\Lib\site-packages\huggingface_hub\file_download.py:140: UserWarning: `huggingface_hub` cache-system uses symlinks by default to efficiently store duplicated files but your machine does not support them in C:\Users\Admin\.cache\huggingface\hub\models--sentence-transformers--all-MiniLM-L6-v2. Caching files will still work but in a degraded version that might require more space on your disk. This warning can be disabled by setting the `HF_HUB_DISABLE_SYMLINKS_WARNING` environment variable. For more details, see https://huggingface.co/docs/huggingface_hub/how-to-cache#limitations.
To support symlinks on Windows, you either need to activate Developer Mode or to run Python as an administrator. In order to activate developer mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development
warnings.warn(message)
model.safetensors: 100%|██████████████████████████████████████████████████████████| 90.9M/90.9M [00:17<00:00, 5.26MB/s]
model_O2.onnx: 100%|██████████████████████████████████████████████████████████████| 90.3M/90.3M [00:31<00:00, 2.86MB/s]
model_O3.onnx: 100%|██████████████████████████████████████████████████████████████| 90.3M/90.3M [00:33<00:00, 2.68MB/s]
model.onnx: 100%|█████████████████████████████████████████████████████████████████| 90.4M/90.4M [00:34<00:00, 2.64MB/s]
model_O1.onnx: 100%|██████████████████████████████████████████████████████████████| 90.4M/90.4M [00:36<00:00, 2.51MB/s]
就自动到huggingface镜像网站下载东西了。问题解决!