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
How to use model.pt in GPU whith C++ API #13245
Comments
See #12686 (comment). |
@goldsborough Yes, I meant to load it with torch::jit::load() and then load or change some trained weights also multiple time directly in c++. |
@bhack You can always access the parameters after and make changes. E.g. use |
Yes I saw the header for single parameter but I meant something like the the equivalent of |
|
@goldsborough I see only a get_parameters at https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/script/module.h#L368 but not a method to set again parameters at once. |
@goldsborough I need also this feature to set all parameters at once to avoid a loop for each parameters, to load the weights in my traced network. |
Hi Joy-yil, Could you share a little more about your setting? I follow the tutorials on https://pytorch.org/tutorials/advanced/cpp_export.html, and add
But errors is thrown when execute the model Error: Thanks, |
@Joshua-Cardio did you move your inputs to CUDA? e.g. with |
Thanks @goldsborough. when using Later I follow your guidance in #12506, and |
Yes #12506 it really needs to be included in the tutorial. |
I'll put it on my list of things to do to expand the tutorial around GPU usage and conversion from and to tensor types :) |
@goldsborough I think that the tutorial could explain also torch.no_grad in c++ and python interfaces. I think that it is a common practice with traced models but it is undocumented. |
Any update on GPU usage? :) |
@ananth-jauntxr it's in the 2nd comment of the thread |
I got the same issue. Can you share with me your final solution in more details? |
Hi, @soumith @goldsborough how can I set gpu id in C++ code? It seems that cudaSetDevice() didn't work. ---update |
I wrapped a pt with Torch Script, and load it with c++ api.
I want to use it in GPU, I can do model.cuda() in python . How can I do it in C++.
The text was updated successfully, but these errors were encountered: