InternVL icon indicating copy to clipboard operation
InternVL copied to clipboard

加载模型时报错: huggingface_hub.utils._errors.FileMetadataError: Distant resource does not have a Content-Length.

Open KZhang152 opened this issue 2 years ago • 2 comments

在调用model = AutoModel.from_pretrained(path, torch_dtype=torch.bfloat16, low_cpu_mem_usage=True, trust_remote_code=True).eval().cuda()时报错信息如下:

Could not locate the configuration_internvl_chat.py inside OpenGVLab/Mini-InternVL-Chat-4B-V1-5. Traceback (most recent call last): File "/root/mambaforge/envs/internvl/lib/python3.9/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.

完整报错信息:

/root/mambaforge/envs/internvl/lib/python3.9/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( Could not locate the configuration_internvl_chat.py inside OpenGVLab/Mini-InternVL-Chat-4B-V1-5. Traceback (most recent call last): File "/root/mambaforge/envs/internvl/lib/python3.9/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/mambaforge/envs/internvl/lib/python3.9/site-packages/transformers/utils/hub.py", line 385, in cached_file resolved_file = hf_hub_download( File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1221, in hf_hub_download return _hf_hub_download_to_cache_dir( File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1325, in _hf_hub_download_to_cache_dir _raise_on_head_call_error(head_call_error, force_download, local_files_only) File "/root/mambaforge/envs/internvl/lib/python3.9/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.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/apprun/zk/InternVL/test_on_20.py", line 102, in model = AutoModel.from_pretrained( File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/transformers/models/auto/auto_factory.py", line 526, in from_pretrained config, kwargs = AutoConfig.from_pretrained( File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/transformers/models/auto/configuration_auto.py", line 1109, in from_pretrained config_class = get_class_from_dynamic_module( File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/transformers/dynamic_module_utils.py", line 488, in get_class_from_dynamic_module final_module = get_cached_module_file( File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/transformers/dynamic_module_utils.py", line 294, in get_cached_module_file resolved_module_file = cached_file( File "/root/mambaforge/envs/internvl/lib/python3.9/site-packages/transformers/utils/hub.py", line 425, in cached_file raise EnvironmentError( OSError: We couldn't connect to 'https://hf-mirror.com' to load this file, couldn't find it in the cached files and it looks like OpenGVLab/Mini-InternVL-Chat-4B-V1-5 is not the path to a directory containing a file named configuration_internvl_chat.py. Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

KZhang152 avatar Jun 19 '24 02:06 KZhang152

解决了吗老哥

ggup13 avatar Jun 25 '24 14:06 ggup13

模型下载不下来也可以通过modelscope下载,这个表里有对应的链接:https://github.com/OpenGVLab/InternVL?tab=readme-ov-file#multimodal-large-language-model-internvl-20

czczup avatar Jul 31 '24 07:07 czczup