-
Notifications
You must be signed in to change notification settings - Fork 44
Importing models saved with pytorch #385
Comments
Thanks for reporting this, @schallerala! We'll take a look when we'll have more time to improve |
@schallerala can you please try installing from branch above and running |
@mike0sv I fail to do so because when running the command you mentioned, I get the following message:
Even though I installed your branch like so: $ python
>>> import torch
>>> torch.cuda.get_arch_list()
['sm_37', 'sm_50', 'sm_60', 'sm_70'] -- and yes, sure of the environment. Have GPUs, tried inside poetry, a virtualenv and even install globally. From the code and tests you submit in your PR, I guess it must be all good, but failed to run what you asked me to |
can you add |
and also try with API?
|
Ok. So 2 problems: First try with
|
Hm, it seems that whatever torch loaded was not a |
Ohh right, you are correct to point that out. Sorry for not raising the matter. I was trying to reproduce the work of torch.save(model.state_dict(), '%s/%s.%d.pkl' % (args.model_dir, args.model_name, itr)) But I guess it is the "standard"/recommanded way, if we read pytorch's documentation What do you suggest? Is it part of the limitation of mlem, as out of its use cases? |
we don't support |
I guess then that the issue can be closed and merge the PR then. Most likely no need to put more effort into it, with the tests you have implemented. Thank you for your help and sorry for the struggle today. Cheers |
NP! |
* lil refactor of import hooks add torch model import closes #385 * fix typo
Using the latest release
0.2.7
, I tried to import models that have been saved usingpytorch
like somlem import ckpt/best.pt ckpt/best
which produced the following error:From my understanding, MLEM doesn't support the new way of pytorch to pickle its model using the
torch.save
method (https://pytorch.org/docs/stable/generated/torch.save.html). Most likely, when we read their note:Additionally, reading at MLEM's source, found out it is "only" able to import pickled models when looking at the subclasses of the
ExtImportHook
(model-wise:PickleImportHook
) (https://github.com/iterative/mlem/blob/HEAD/mlem/core/import_objects.py#L56-L67).Therefore, I guess I better change the source code and use MLEM's
save
method, to persist models; but believe it could be a great new feature of theimport
command :)Leaving it here to the pros! 👨🏼🎤
Best,
The text was updated successfully, but these errors were encountered: