johnma2006 / mamba-minimal

Simple, minimal implementation of the Mamba SSM in one file of PyTorch.
Apache License 2.0
2.54k stars 188 forks source link

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

Open WenjunHuang94 opened 5 months ago

WenjunHuang94 commented 5 months ago

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 commented 5 months ago

The same question.

WenjunHuang94 commented 4 months ago

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

9f092222f43bc1932e7bfa5290fc4c9 https://hf-mirror.com

Tiandooo commented 4 months ago

我也解决了,感谢

WenjunHuang94 commented 4 months ago

是用我说的方法解决的吗

Tiandooo commented 4 months ago

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

LiZijunApril commented 3 months ago

下载到本地的模型也可以,要修改一下代码。 这个错误的直接原因是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