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

AttributeError: 'NoneType' object has no attribute 'seek'. You can only torch.load from a file that is seekable #27

Open
WenjunHuang94 opened this issue Apr 15, 2024 · 7 comments

Comments

@WenjunHuang94
Copy link

Hello.

Error 'AttributeError:' NoneType 'object has no attribute' seek '. You can only torch. load from a file that is searchable. Please pre load the data into a buffer like io.BytesIO and try to load from it install.'.

I have assigned weights and the file path is also correct. I don't know how to solve it. May I ask for your advice

image

image

969d94c1ea973d3bcc0fccab1356b9d

@Tiandooo
Copy link

The same question.

@WenjunHuang94
Copy link
Author

我已经解决了。就是配置了hugging face的镜像,就能自己成功了。
(1) pip install -U huggingface_hub
(2)将 huggingface_hub下的constants.py里的ENDPOINT改成镜像
5e235498abf54734cb14194535e3be9

9f092222f43bc1932e7bfa5290fc4c9
https://hf-mirror.com

@Tiandooo
Copy link

我也解决了,感谢

@WenjunHuang94
Copy link
Author

是用我说的方法解决的吗

@Tiandooo
Copy link

对的,不知道为什么他这个代码用下到本地的model不可以,必须用镜像下载

@LiZijunApril
Copy link

LiZijunApril commented Jun 12, 2024

下载到本地的模型也可以,要修改一下代码。
这个错误的直接原因是Mamba类里from_pretrained方法中的load_state_dict_hf函数里,使用的cached_file(model_name, WEIGHTS_NAME),这里的WEIGHTS_NAME通常是'pytorch_model.bin',表示保存和加载模型权重的默认文件名。但是下载到本地的模型提供的权重文件是'model.safetensors',所以要用safetensors库中的torch.load_file加载:

code

加载完了之后,不知道为什么权重跟结构对不上,要稍微修改一下,在return model之前:
code

@tangser
Copy link

tangser commented Oct 17, 2024

可以的!楼上方法可行!

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

4 participants