実現したいこと
PytorchにおいてBERTのファインチューニング済みモデルを保存したい。
前提
pth形式でモデルを保存しようとしたら謎のエラーを吐かれています(´;ω;`)
以前pth形式でモデルを保存できたのでなぜかわからなくなってしまったので質問しております。
発生している問題・エラーメッセージ
RuntimeError Traceback (most recent call last) Cell In[17], line 1 ----> 1 torch.save(model.state_dict(),"/model_test1.pt") File c:\Users\gp20a180\anaconda3\envs\bert\lib\site-packages\torch\serialization.py:440, in save(obj, f, pickle_module, pickle_protocol, _use_new_zipfile_serialization) 437 _check_save_filelike(f) 439 if _use_new_zipfile_serialization: --> 440 with _open_zipfile_writer(f) as opened_zipfile: 441 _save(obj, opened_zipfile, pickle_module, pickle_protocol) 442 return File c:\Users\gp20a180\anaconda3\envs\bert\lib\site-packages\torch\serialization.py:315, in _open_zipfile_writer(name_or_buffer) 313 else: 314 container = _open_zipfile_writer_buffer --> 315 return container(name_or_buffer) File c:\Users\gp20a180\anaconda3\envs\bert\lib\site-packages\torch\serialization.py:288, in _open_zipfile_writer_file.__init__(self, name) 287 def __init__(self, name) -> None: --> 288 super().__init__(torch._C.PyTorchFileWriter(str(name))) RuntimeError: File /model_test1.pt cannot be opened.
該当のソースコード
python
1torch.save(model.state_dict(),"/model_test1.pth") ->2023/09/04に編集済み
試したこと
自力で調べたが解決策なし
補足情報(FW/ツールのバージョンなど)
Pytorch = 2.0.1
cuda = 11.8
python = 3.9.16

回答1件
あなたの回答
tips
プレビュー