FastAI on Kaggle : AttributeError: Can't get attribute '_rebuild_from_type

I am trying to submit to the (closed) plant pathology 2021 competition. I trained a model on colab, using fastai, exported it using learn.export then uploaded it to kaggle, ran it, but am getting this error.
code used to get to this error:

learner = load_learner(m, cpu=False).to_fp32()
test_dl = learner.dls.test_dl(sample)

I’ve initialized the functions used in colab to train like get_x and get_y

I’ve ran this with and without GPU, I’ve run this with and without the fp_32 flag.

The only thing i can see wrong is that the version of pytorch and fastai used to make the model are newer than the ones running on kaggle for offline-only notebooks.
I’d appreciate any help to figure this out.

Next i’m gonna try do the training on kaggle and see if that matters.

Thank you

AttributeError                            Traceback (most recent call last)
<ipython-input-6-42c0bbf20590> in <module>
      1 predictions = 0
----> 2 learner = load_learner(m, cpu=False).to_fp16()
      3 test_dl = learner.dls.test_dl(sample)
      4 preds, _ = learner.tta(dl=test_dl)
      5 predictions += preds

/opt/conda/lib/python3.7/site-packages/fastai/ in load_learner(fname, cpu, pickle_module)
    373     "Load a `Learner` object in `fname`, optionally putting it on the `cpu`"
    374     distrib_barrier()
--> 375     res = torch.load(fname, map_location='cpu' if cpu else None, pickle_module=pickle_module)
    376     if hasattr(res, 'to_fp32'): res = res.to_fp32()
    377     if cpu: res.dls.cpu()

/opt/conda/lib/python3.7/site-packages/torch/ in load(f, map_location, pickle_module, **pickle_load_args)
    593                     return torch.jit.load(opened_file)
--> 594                 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
    595         return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)

/opt/conda/lib/python3.7/site-packages/torch/ in _load(zip_file, map_location, pickle_module, pickle_file, **pickle_load_args)
    851     unpickler = pickle_module.Unpickler(data_file, **pickle_load_args)
    852     unpickler.persistent_load = persistent_load
--> 853     result = unpickler.load()
    855     torch._utils._validate_loaded_sparse_tensors()

AttributeError: Can't get attribute '_rebuild_from_type' on <module 'fastai.torch_core' from '/opt/conda/lib/python3.7/site-packages/fastai/'>

That’s your issue. You should make a dataset usually with the torch and fastai versions you want to use (or find one) for the offline stuff

Thank you. I will keep this in mind and see if i can redo on kaggle.