RuntimeError when exporting a model

When trying to export a model in VSCode on my M1 Mac with

learn.export('model.pkl')

I get following error:
‘RuntimeError: don’t know how to determine data location of torch.storage._UntypedStorage’

Anybody knows how to solve this problem?

I found your error message mentioned here

I saw that too, but that doesn’t rellay help me :slightly_frowning_face:

Oh. Thats dissapointing.

It really really helps to describe what you’ve already tried and learnt, particularly for the next person that encounters the same problem searching for an answer. For example, I’m sure you’ve checked how your current python version compares to the environment reported for that bug. Let us know. That is useful information for those in the community that would like to help you.
image

Also for example, I’m sure that you’ve tried reproducing the YOLO5 error, using the given Minimal Reproducible Example. Their Quickstart example seems pretty simple. So please report the exact command/response you got from that. Since currently google results for your error message are current very scarce, and the YOLO5 bug was reported very recently, only a month ago, maybe very few people have encountered your issue.

Please read How To Ask Questions The Smart Way paying particular attention to “display the fact that you have done these things.” Hopefully we can help you find an answer to your issue.

1 Like

Sorry for my ignorance, but I don’t really get how the YOLO5 error is related to mine.
My problem occurs when I use the export() function from fastai.
I use the same python version as in the reported bug, but my pytorch version is 1.12.0 instead of the nightly build, simply because fastai overrides the pytorch version for compatibility reasons I guess.

Hi @HoangLong, Have you managed to solve this yet?

I was curious to see what change was made in the PR that fixed that YOLO issue I linked above, and its interesting that the fix seems to be to force cpu usage.

You don’t mention that you’ve tried any simple test programs like the following, so can you report if they work for you?

  1. “Verifying the installation” on this page

  2. “Step 8” on this page

  3. “run a simple program” half way down this page

  4. “Step 4 Testing” on this page

If they do all work, then sorry I’m lacking any more useful tips. HTH.

I can’t reproduce this issue on M1 Mac with fastai 2.7.7/torch 1.12.0. This runs successfully.

learn = vision_learner(dls, resnet18, metrics=error_rate, lr=0.15)
learn.export(‘model.pkl’)

Are you using a custom model?

1 Like

All of the steps work fine.
I’m guessing it has something to do with the missing ‘mps’ support in ‘serialization.py’ in pytorch. I have pytorch 1.12 installed, but when comparing with the github code somehow I am missing the code for 'mps" support.

1 Like

Also using fastai 2.7.7/torch 1.12.0. No custom model. Just trying out this notebook locally on VSCode:

1 Like