Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while deserializing header: HeaderTooLarge #302

Open
jack161641 opened this issue Mar 11, 2024 · 1 comment
Open

Error while deserializing header: HeaderTooLarge #302

jack161641 opened this issue Mar 11, 2024 · 1 comment

Comments

@jack161641
Copy link

跑ReadMe的Demo code都报错,该怎么解决?

SafetensorError Traceback (most recent call last)
Cell In[4], line 5
3 model_path = '/home/admin/Atom-7B-Chat'
4 device_map = "cuda:0" if torch.cuda.is_available() else "auto"
----> 5 model = AutoModelForCausalLM.from_pretrained(model_path,device_map=device_map,torch_dtype=torch.float16,load_in_8bit=True,trust_remote_code=True,use_flash_attention_2=True)
6 model =model.eval()
7 tokenizer = AutoTokenizer.from_pretrained(model_path,use_fast=False)

File ~/anaconda3/envs/py3.8/lib/python3.8/site-packages/transformers/models/auto/auto_factory.py:556, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
554 else:
555 cls.register(config.class, model_class, exist_ok=True)
--> 556 return model_class.from_pretrained(
557 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
558 )
559 elif type(config) in cls._model_mapping.keys():
560 model_class = _get_model_class(config, cls._model_mapping)

File ~/anaconda3/envs/py3.8/lib/python3.8/site-packages/transformers/modeling_utils.py:3502, in PreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)
3493 if dtype_orig is not None:
3494 torch.set_default_dtype(dtype_orig)
3495 (
3496 model,
3497 missing_keys,
3498 unexpected_keys,
3499 mismatched_keys,
3500 offload_index,
3501 error_msgs,
-> 3502 ) = cls._load_pretrained_model(
3503 model,
3504 state_dict,
3505 loaded_state_dict_keys, # XXX: rename?
3506 resolved_archive_file,
3507 pretrained_model_name_or_path,
3508 ignore_mismatched_sizes=ignore_mismatched_sizes,
3509 sharded_metadata=sharded_metadata,
3510 _fast_init=_fast_init,
3511 low_cpu_mem_usage=low_cpu_mem_usage,
3512 device_map=device_map,
3513 offload_folder=offload_folder,
3514 offload_state_dict=offload_state_dict,
3515 dtype=torch_dtype,
3516 hf_quantizer=hf_quantizer,
3517 keep_in_fp32_modules=keep_in_fp32_modules,
3518 )
3520 # make sure token embedding weights are still tied if needed
3521 model.tie_weights()

File ~/anaconda3/envs/py3.8/lib/python3.8/site-packages/transformers/modeling_utils.py:3903, in PreTrainedModel._load_pretrained_model(cls, model, state_dict, loaded_keys, resolved_archive_file, pretrained_model_name_or_path, ignore_mismatched_sizes, sharded_metadata, _fast_init, low_cpu_mem_usage, device_map, offload_folder, offload_state_dict, dtype, hf_quantizer, keep_in_fp32_modules)
3901 if shard_file in disk_only_shard_files:
3902 continue
-> 3903 state_dict = load_state_dict(shard_file)
3905 # Mistmatched keys contains tuples key/shape1/shape2 of weights in the checkpoint that have a shape not
3906 # matching the weights in the model.
3907 mismatched_keys += _find_mismatched_keys(
3908 state_dict,
3909 model_state_dict,
(...)
3913 ignore_mismatched_sizes,
3914 )

File ~/anaconda3/envs/py3.8/lib/python3.8/site-packages/transformers/modeling_utils.py:505, in load_state_dict(checkpoint_file)
500 """
501 Reads a PyTorch checkpoint file, returning properly formatted errors if they arise.
502 """
503 if checkpoint_file.endswith(".safetensors") and is_safetensors_available():
504 # Check format of the archive
--> 505 with safe_open(checkpoint_file, framework="pt") as f:
506 metadata = f.metadata()
507 if metadata.get("format") not in ["pt", "tf", "flax"]:

SafetensorError: Error while deserializing header: HeaderTooLarge

@zhushuaiCoding
Copy link

解决了吗,我也有这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants