-
Notifications
You must be signed in to change notification settings - Fork 35
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
gotorch can load pytorch models? #378
Comments
+1 I see that the code loads model saved using gop package. As such we need a separation layer which will allow to load pre-trained models using different formats. From mnist.go example file I see that |
I'm mostly interested in inference part which will allow to develop |
@vkuznet Have you found a workaround for loading |
@vkuznet Thanks. Can I use ONNX to convert |
@modanesh , I only used ONNX to convert PyTorch to TensorFlow format, therefore you should try it out and see if it can to convert to gob one. In any way, feel free to open ticket with ONNX for that, and you may open ticket here to use native ONNX format too. |
@vkuznet I did open a ticket in the ONNX's repo, waiting for feedback. |
I am glad you are interested in gotorch. Just dump something in my mind for your reference. I began the project as an experiment. I stopped taking care of it because cgo has terrible performance and the Go team made it clear that cgo will be a feature, but they won't try to make it faster. I learned these things when I worked on goplus. A probably more important reason is that I couldn't find an easy way to make sure that Go's GC releases GPU memory on time. This is more deadly for training than for inference. But I'm afraid that the GC might slow down online inference irregularly http://big-elephants.com/2018-09/unexpected-gc-pauses/. Back to your question about loading models. I think we will need a higher layer than gotorch, something like Google pax over jax, which defines models, modules, parameters, buffers, etc. on top of the low-level concept tensor. It would be easier to implement parameter loading in that higher layer. |
@wangkuiyi Thanks for the explanation, very much appreciated. Asking for advice (a bit deviated from the issue's topic), what's a good approach to using a deep model in production? Initially, I wanted to avoid running it in Python since it's inherently slow. Thus, I came across Go and wanted to run my model in Go but as you suggested, it doesn't look like a nice way. The last remaining option would be TensorRT AFAIK. What do you think? |
I haven't seen a single way to serving that works for all cases yet. In my role with PyTorch Distributed and TorchRec, I saw the following solutions in use. Let us cross-validate our observations.
|
Thanks for the thorough explanation. To provide some context, I currently have a server implemented in Go that sends WebRTC streams. I want to capture this stream and perform some CV processings on it. I'm able to do so with PyTorch, but that's a bit slow, resulting in ~10 FPS (I want to be real-time). To improve processing speed, I have considered a few options: As my model is based on ResNet, I do not think that FastTransformer and Distributed Embedding Tables would be very helpful. And given that the model can be loaded on a single 1080ti GPU, I believe TorchServe could be helpful. I'm going to give it a try and see how it goes (thanks to your pointers). If it does not improve processing speed, I will consider using TensorRT as my next option. |
Hi, this is awsome project ! but I have a question: gotorch can load the pytorch model, I want use gotorch only in predict
The text was updated successfully, but these errors were encountered: