互联网的意义在于高质量的共享
1.报错情景
模型单个epoch训练结束后保存时
2.报错信息
AttributeError: Can't pickle local object 'EMASlideLoss.__init__.<locals>.<lambda>'
WARNING:torch.distributed.elastic.multiprocessing.api:Sending process 330776 closing signal SIGTERM
3.可能问题
pickle库导入有问题
4.解决方案
在报错的文件中,将import pickle改成import dill as pickle
文件路径(Linux环境):/home/amax/anaconda3/envs/XXX/lib/python3.9/site-packages/torch/serialization.py
!!!注意,此时要先安装dill库
import pickle
改为:
import dill as pickle
大功告成!