Oneflow-Inc / oneflow

OneFlow is a deep learning framework designed to be user-friendly, scalable and efficient.
http://www.oneflow.org
Apache License 2.0
5.95k stars 669 forks source link

无法保存模型文件 #10337

Open levi131 opened 1 year ago

levi131 commented 1 year ago

Summary

使用0.9.1.dev20230630+cu117版本的oneflow在保存由torch转换的模型时在最后报错。使用0.9.0版本不会报错,能成功保存模型

Code to reproduce bug

from models.NLP.roberta.models.roberta import Roberta flow_model = Roberta(**kwargs) flow_model.load_state_dict(torch_para, False) flow.save(flow_model.state_dict(), "/root/autodl-tmp/oneflow_trans/oneflow/chemberta")

报错: Traceback (most recent call last): File "chemberta.py", line 35, in flow.save(flow_model.state_dict(), "/code/oneflow/oneflow_chemberta") File "/opt/conda/lib/python3.8/site-packages/oneflow/framework/check_point_v2.py", line 737, in save write_file() File "/opt/conda/lib/python3.8/site-packages/oneflow/framework/check_point_v2.py", line 723, in write_file with _open_file_like(path_or_buffer, "wb") as f: File "/opt/conda/lib/python3.8/site-packages/oneflow/framework/check_point_v2.py", line 99, in _open_file_like return _open_file(path_or_buffer, mode) File "/opt/conda/lib/python3.8/site-packages/oneflow/framework/check_point_v2.py", line 80, in init super(_open_file, self).init(open(path, mode)) IsADirectoryError: [Errno 21] Is a directory: '/code/oneflow/oneflow_chemberta'

System Information

levi131 commented 1 year ago

在https://github.com/Oneflow-Inc/oneflow/pull/10338 中修复