我训练了一个模型,并把它和pickle放在一起。但是当我尝试在另一个ubuntu上加载它时,它显示了错误
AttributeError: Can't get attribute '_VariableFunctionClass' on <module 'torch._C' from 'xxx/torch/_C.cpython-37m-x86_64-linux-gnu.so'>'
我尝试了以下方法,但不起作用:
class CustomUnpickler(pickle.Unpickler):
def find_class(self, module, name):
try:
return super().find_class(__name__, name)
except AttributeError:
return super().find_class(module, name)
pickle_data = CustomUnpickler(open(path, 'rb')).load()
我还尝试了用cpu训练的pickle,它不会触发那个错误。所以我想知道是否是GPU依赖性导致了这个问题
提前谢谢
目前没有回答
相关问题 更多 >
编程相关推荐