AttributeError: 'Linear' object has no attribute '_lazy_load_hook'

Hello all,
I am facing a very weird issue when loading a saved model using pickle.load. I had trained a pyG GCN model and saved it like this:

import pickle
path = '/content/drive/MyDrive/'
file = open(path + 'bamodel', 'wb')
pickle.dump(model, file)

I am loading it like this:

import pickle

# open a file, where you stored the pickled data
path = '/content/drive/MyDrive/'
file = open(path+ 'bamodel', 'rb')

model = pickle.load(file)

But, when I try to load the model, I receive the error:

AttributeError: ‘Linear’ object has no attribute ‘_lazy_load_hook’
I have started facing the issue today, while I was not facing the issue earlier

Neither did I change the ‘bamodel’ file, nor anything else, so I am pretty surprised at why is this error coming up. I searched the internet but no on else seems to have faced this issue before. Any help is greatly appreciated!

I also meet this problem, I regenerate the pickled file and use the same path. It works

Thanks for your reply! The issue is that, in my case I only want to use the saved model(model training is stochastic, so it is difficult to regenerate the same model state) in the pickle file. So, if I regenerate the pickle file, then I will lose the model that I had saved. Do you know any way by which I can use the same pickle file?