-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Open
Labels
module: optimizerRelated to torch.optimRelated to torch.optimtodoNot as important as medium or high priority tasks, but we will work on these.Not as important as medium or high priority tasks, but we will work on these.triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
I think the optimizers and schedulers could use some extra work.
The main thing I would love, is for optimizers and schedulers to have a to() method so we can send their parameters to a certain device. This would allow us to save the parameters and reload them at a later stage without any problems.
Right now, the following script crashes with an error that the optimizer expects a torch.FloatTensor but got a torch.cuda.FloatTensor. I am not quite sure why, as I specifically load the data to CPU?
# Note: This is not my actual script, but rather a representation of the steps and in what order I perform them
network = ... # Creating a network based of torch.nn.Module
optim = torch.optim.SGD(network.parameters(), ...)
state = torch.load('file_path', lambda storage, loc: storage) # Send all tensors to CPU
network.load_state_dict(state['network'])
optim.load_state_dict(state['optim'])
network.to(torch.device('cuda'))
#optim.to(torch.device('cuda')) # Would this solve my problems? The same could be said about schedulers.
shoaibahmed and rees-c
Metadata
Metadata
Assignees
Labels
module: optimizerRelated to torch.optimRelated to torch.optimtodoNot as important as medium or high priority tasks, but we will work on these.Not as important as medium or high priority tasks, but we will work on these.triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module