Loading a pickle file gives "AttributeError: type object 'EnglishDefaults' has no attribute 'is_base_form'" error

I am getting the above mentioned error while loading a pickle file. Please let me know how to handle this.

The code used is

learn_cls = load_learner(fname=path/‘new_72_seq_length_alldesc_with_spaces_87.pkl’)

and error stack trace is


AttributeError Traceback (most recent call last)
in ()
----> 1 learn_cls = load_learner(fname=path/‘new_72_seq_length_alldesc_with_spaces_87.pkl’)

/usr/local/lib/python3.6/dist-packages/fastai/learner.py in load_learner(fname, cpu)
547 "Load a Learner object in fname, optionally putting it on the cpu"
548 distrib_barrier()
–> 549 res = torch.load(fname, map_location=‘cpu’ if cpu else None)
550 if hasattr(res, ‘to_fp32’): res = res.to_fp32()
551 if cpu: res.dls.cpu()

/usr/local/lib/python3.6/dist-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
582 opened_file.seek(orig_position)
583 return torch.jit.load(opened_file)
–> 584 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
585 return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
586

/usr/local/lib/python3.6/dist-packages/torch/serialization.py in _load(zip_file, map_location, pickle_module, **pickle_load_args)
840 unpickler = pickle_module.Unpickler(data_file, **pickle_load_args)
841 unpickler.persistent_load = persistent_load
–> 842 result = unpickler.load()
843
844 return result

AttributeError: type object ‘EnglishDefaults’ has no attribute ‘is_base_form’

This pickle file loading works on source machine(on which it is generated), but doesn’t get loaded on google colab

Here are specs of machine involved
Source Machine:
fastai version: ‘2.0.16’
pytorch version: ‘1.6.0’
Cuda version: V10.0.130

Colab specs: (loading the pickle file)
fastai version: ‘2.0.16’
pytorch version: 1.6.0+cu101
Cuda version: V10.1.243

Is version an issue? Or anything else? Please guide me on this.

Update: Later today I upgraded my GPU to exact same version of CUDA that is present on colab. Still have the error.

Does the uploading of pkl file to google drive add any additional headers on top of the file ? I am running out of debug options here.

Regards,
Chaitanya Kanth.

@muellerzr

I am having the same problem. Any help would be greatly appreciated!

Hello @mzrizvi, The issue is with the python version. My source machine was having python 3.8.2 and pickling mechanism on 3.8.2 involves some advanced techniques that are not available on 3.6.x or 3.7.x. (collab specifically uses 3.6.x)

So please keep your python versions same inorder to avoid this conflict.

1 Like

Hi @mzrizvi I have a similar problem, my model was trained on a VM with python 3.9.7 and when I wanted to test the final model in my google colab it gives me the same error: AttributeError: type object ‘EnglishDefaults’ has no attribute ‘is_base_form’
What did you do to solve this? I couldn’t change the python version in google colab