The Wayback Machine - https://web.archive.org/web/20200530085841/https://github.com/PyTorchLightning/pytorch-lightning/issues/1532
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load checkpoint from URL #1532

Open
williamFalcon opened this issue Apr 19, 2020 · 5 comments · May be fixed by #1667
Open

load checkpoint from URL #1532

williamFalcon opened this issue Apr 19, 2020 · 5 comments · May be fixed by #1667

Comments

@williamFalcon
Copy link
Collaborator

@williamFalcon williamFalcon commented Apr 19, 2020

Let's enable loading weights from a URL directly

Option 1:

Automate it with our current API

Trainer.load_from_checkpoint('http://')

Option 2:

Have a separate method

Trainer.load_from_checkpoint_at_url('http://')

Resources

We can use this under the hood:
(https://pytorch.org/docs/stable/hub.html#torch.hub.load_state_dict_from_url)

Any thoughts on which one is better?
@PyTorchLightning/core-contributors

@yukw777
Copy link
Contributor

@yukw777 yukw777 commented Apr 20, 2020

I recently had to implement a similar functionality and I found this library very useful: https://github.com/RaRe-Technologies/smart_open. It handles various protocols other than http(s) like s3 with a very simple interface like python’s default file open. Thought you might be interested.

@jeremyjordan
Copy link
Contributor

@jeremyjordan jeremyjordan commented Apr 20, 2020

slight preference for option 1

@williamFalcon
Copy link
Collaborator Author

@williamFalcon williamFalcon commented Apr 20, 2020

@yukw777 nice. want to submit a PR?
Seems like overkill for the first instance no? we want to keep this simple.

Maybe we do a v1 that supports http, https only?
Expand functionality in v2 for other protocols?

@yukw777
Copy link
Contributor

@yukw777 yukw777 commented Apr 20, 2020

@williamFalcon yeah i can give it a shot. I just read the code of load_state_dict_from_url and it seems like we don't really need to use smart_open for this, so I'll proceed without that. I also prefer Option 1.

A few questions:

  1. Should we provide a default directory to which we'd download the checkpoints? If so, where?
  2. What's your recommendation on writing tests for this? It'd be simplest to have a test checkpoint file uploaded somewhere and just download that...
@justusschock
Copy link
Member

@justusschock justusschock commented Apr 21, 2020

Maybe we'll also use torch cache for that? Since after all it's still a PyTorch model? Or do we want to create yet another cache?

@yukw777 yukw777 linked a pull request that will close this issue Apr 29, 2020
1 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.