mamba-minimal icon indicating copy to clipboard operation
mamba-minimal copied to clipboard

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

Open WenjunHuang94 opened this issue 10 months ago • 6 comments

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

WenjunHuang94 avatar Apr 15 '24 03:04 WenjunHuang94

The same question.

Tiandooo avatar Apr 24 '24 08:04 Tiandooo

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

9f092222f43bc1932e7bfa5290fc4c9 https://hf-mirror.com

WenjunHuang94 avatar Apr 25 '24 07:04 WenjunHuang94

我也解决了,感谢

Tiandooo avatar Apr 25 '24 07:04 Tiandooo

是用我说的方法解决的吗

WenjunHuang94 avatar Apr 25 '24 07:04 WenjunHuang94

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

Tiandooo avatar Apr 25 '24 07:04 Tiandooo

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

LiZijunApril avatar Jun 12 '24 08:06 LiZijunApril

可以的!楼上方法可行!

tangser avatar Oct 17 '24 08:10 tangser