-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
save model issue #39
Comments
Hi, I noticed this issue report in the early, however I test the code on Windows and CentOS, but cannot reproduce this problem. I suppose the reason is the version of pickle. I will fix this problem as soon as I can. Please watch the new release on PyPi. |
Great! Appreciate |
As a suggestion, you can uncomment
|
The model loading code is compatible with the model saved in state_dict mode. Please let me know if this works or not, many thanks. |
Got it. I'll try it later and send you the feedback. Thank you for the quick reply and solutions. |
You are welcome! Can you export the package list to help reproduce the problem? |
Package Version anyio 2.2.0
|
I cant reproduce the problem, still. However, I found some answers saying it may be caused by locked logger while saving model. I revise some code about logger in V0.8.8.2,please help me review if the code works. |
According to a test report, this problem occurs on some situations has been solved in 0.8.8.2 . Thanks for your help. |
It works perfect. Brilliant! |
There's an error when i tried to train the model on my dataset.
Traceback (most recent call last):
File "train.py", line 29, in
auto_device=True # Auto choose CUDA or CPU
File "/home/hsz/.conda/envs/win_env/lib/python3.6/site-packages/pyabsa/functional.py", line 157, in train_atepc
model_path.append(train4atepc(t_config))
File "/home/hsz/.conda/envs/win_env/lib/python3.6/site-packages/pyabsa/tasks/atepc/training/atepc_trainer.py", line 382, in train4atepc
return trainer.train()
File "/home/hsz/.conda/envs/win_env/lib/python3.6/site-packages/pyabsa/tasks/atepc/training/atepc_trainer.py", line 204, in train
self._save_model(self.opt, self.model, save_path, mode=0)
File "/home/hsz/.conda/envs/win_env/lib/python3.6/site-packages/pyabsa/tasks/atepc/training/atepc_trainer.py", line 354, in _save_model
torch.save(model_to_save.cpu(), save_path + args_to_save.model_name + '.model') # save the whole model
File "/home/hsz/.conda/envs/win_env/lib/python3.6/site-packages/torch/serialization.py", line 379, in save
_save(obj, opened_zipfile, pickle_module, pickle_protocol)
File "/home/hsz/.conda/envs/win_env/lib/python3.6/site-packages/torch/serialization.py", line 484, in _save
pickler.dump(obj)
TypeError: can't pickle _thread.RLock objects
Seems that one or some objects in self.model that cannot be dumped by pickle.
But if I change the saving mode to any value but 0, the _save_model function works well. So i guess the difference could be the type of model that i saved, which means 'pytorch.bin' can be generated but '.model' file cannot.
Could you help me out, thx
The text was updated successfully, but these errors were encountered: