赞
踩
最近跑代码遇到了一个奇怪的问题:
OSError: Unable to load weights from pytorch checkpoint file for '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7' at '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
OSError: Unable to load weights from pytorch checkpoint file for '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7' at '/root/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
报错最后一句是“If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.”
我要加载的模型文件并不是Tensorflow格式的,就算在加载模型的那一行代码里面添加参数from_tf=True还是会报错
进入以下目录:(不同用户的路径可能不太一样)
/root/.cache/huggingface/transformers
找到报错的那个文件,我这里是:“c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7”
这个文件下面分别有以.json和.lock结尾的文件,一共三个文件全部删了
再次运行代码会从huggingface上重新下载相关文件,然后就不会报错了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。