datawhalechina / self-llm

《开源大模型食用指南》基于Linux环境快速部署开源大模型,更适合中国宝宝的部署教程
Apache License 2.0
6.08k stars 748 forks source link

Index-1.9B-Chat webDemo部署报错问题 #166

Open gzhuuser opened 2 weeks ago

gzhuuser commented 2 weeks ago

使用下载模型的代码后出现下面的报错,后面改用官方的才把权重文件下好

Traceback (most recent call last): File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1754, in _get_metadata_or_catch_error raise FileMetadataError("Distant resource does not have a Content-Length.") huggingface_hub.utils._errors.FileMetadataError: Distant resource does not have a Content-Length.

修改后的代码

# 使用镜像加快下载
import os
from transformers import pipeline
os.environ['HF_ENDPOINT'] = "https://hf-mirror.com"

pipe = pipeline("text-generation", model="IndexTeam/Index-1.9B-Chat", trust_remote_code=True)

在webDemo中更改一下模型路径,改成

model_name_or_path = 'IndexTeam/Index-1.9B-Chat'
gzhuuser commented 2 weeks ago

补充报错信息

root/miniconda3/lib/python3.10/site-packages/huggingface_hub/file_download.py:1132: FutureWarning: resume_download is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use force_download=True. warnings.warn( Fetching 12 files: 33%|███████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 4/12 [00:00<00:01, 7.10it/s] pytorch_model.bin: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4.35G/4.35G [10:37<00:00, 6.82MB/s] Traceback (most recent call last): File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1754, in _get_metadata_or_catch_error raise FileMetadataError("Distant resource does not have a Content-Length.") huggingface_hub.utils._errors.FileMetadataError: Distant resource does not have a Content-Length. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/root/download.py", line 7, in model_dir = snapshot_download('IndexTeam/Index-1.9B-Chat', local_dir='/root/autodl-tmp/IndexTeam/Index-1.9B-Chat', resume_download=True) File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, kwargs) File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/_snapshot_download.py", line 294, in snapshot_download thread_map( File "/root/miniconda3/lib/python3.10/site-packages/tqdm/contrib/concurrent.py", line 94, in thread_map return _executor_map(ThreadPoolExecutor, fn, *iterables, *tqdm_kwargs) File "/root/miniconda3/lib/python3.10/site-packages/tqdm/contrib/concurrent.py", line 76, in _executor_map return list(tqdm_class(ex.map(fn, iterables, map_args), kwargs)) File "/root/miniconda3/lib/python3.10/site-packages/tqdm/std.py", line 1195, in iter for obj in iterable: File "/root/miniconda3/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator yield _result_or_cancel(fs.pop()) File "/root/miniconda3/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel return fut.result(timeout) File "/root/miniconda3/lib/python3.10/concurrent/futures/_base.py", line 458, in result return self.get_result() File "/root/miniconda3/lib/python3.10/concurrent/futures/_base.py", line 403, in get_result raise self._exception File "/root/miniconda3/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, *self.kwargs) File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/_snapshot_download.py", line 268, in _inner_hf_hub_download return hf_hub_download( File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(args, kwargs) File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1202, in hf_hub_download return _hf_hub_download_to_local_dir( File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1440, in _hf_hub_download_to_local_dir _raise_on_head_call_error(head_call_error, force_download, local_files_only) File "/root/miniconda3/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1826, in _raise_on_head_call_error 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.

KMnO4-zx commented 2 weeks ago

好的,感谢您提供的报错信息!

Kedreamix commented 2 weeks ago

@gzhuuser 最新代码加入modelscope下载方式,解决hugginghub下载问题,可替换代码

import torch
from modelscope import snapshot_download, AutoModel, AutoTokenizer
import os

model_dir = snapshot_download('IndexTeam/Index-1.9B-Chat', cache_dir='/root/autodl-tmp', revision='master')