-
Notifications
You must be signed in to change notification settings - Fork 167
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
Module.save
moves Module
to CPU
#372
Comments
I did it that way because it was the quick and safe thing to do, and documented it in the article on saving and loading. If the difference in behavior is truly problematic, it should be relatively straight-forward to address it. |
(save is moving model to CPU)
@NiklasGustafsson what article are you referring to? The C++ frontend documentation has no remarks about CPU vs CUDA tensors for |
@lostmsu I'm sorry -- I'm not quite sure I understand what statement of mine you are referring to. |
@NiklasGustafsson oh, sorry, I thought
refers to PyTorch documentation, not TorchSharp documentation you wrote. Still I don't see anything in PyTorch C++ documentation, that would suggest, that tensors need to be moved to CPU in order to save them. Does Perhaps it will make more sense to make a CPU copy of the tensor before saving it instead of moving. |
Right. My statement was intended to refer to the TorchSharp article. With this latest PR, the tensor is moved to the CPU, then moved back to where it came from. I'll look into making a copy, instead. The problem is that the .NET logic to saving and loading tensors is based on Span, which cannot accept a pointer to GPU memory, so it has to be in CPU memory to work. |
Turns out, copy works on save(), but not on load(). |
Version: 0.93.0.0
In contrast in Python
torch.save(module, path)
does not.The text was updated successfully, but these errors were encountered: