Anyone tried out the PyTorch Mobile demo apps yet?

No kidding. I hit a thing loading parameters where it just said “something ending with weight cannot be found in the saved model file”… Glad that is fixed now to give the full hierarchy. :slight_smile: I think this is more C++ than Android-specific.
It’s still strange that you would have that error message from a model that doesn’t have custom tensor type ids (because as far as I can see that error message is for unknown type ids and should be the same for mobile vs. PC). Does the model load on the computer if you use PyTorch 1.3?

Best regards

Thomas

Blockquote Also, another question: is PyTorch mobile stable enough and suitable for production? Or should we just use ONNX and Caffe 2 until it is more mature?

The feature is still experimental so we do expect rough edges as this is brand new as of this quarter. We are, in parallel, working through production deployment inside FB and so the code base is improving on a daily basis. If you are looking for something that is moving slower and super stable in the short term, the ONNX export path is probably your best bet (i.e. ONNX+CoreML for iOS, etc…). Let us know if we can help on your prod deployment here.

1 Like

thanks @Kareem_Belgharbi for the feedback and comments. We can definitely improve error messaging for the next release.

for the API comments, can you elaborate on what you find nice?

Is there a way to shrink the size of the Pytorch lib on mobile deployment? We compiled the demo app without the model and the app size was ~79Mb. Pretty great so far. Much fewer headaches than TFLite to get models on the phone.

I like how it’s very simple and to the point, and has nice convenience functions for working with images. I also really like how easy it is to go from tensors to IValues and convert data to tensors, but what I like most is how easy the conversion process is since it uses .pt files. With TensorFlow Lite I would always get a conversion error that would take forever to debug but here it’s painless.

1 Like

I ended up fixing the error but unfortunately I don’t remember how. I did end up getting a whole bunch of other import errors mostly from import.cpp, but in the end it tuned out that I had compiled the model with a different version of PyTorch.

very helpful, thanks for sharing!

Edit: solved this. I’m not entirely sure since I changed a couple of things, but my best guess as to what caused this is either doing a variable.int() or having multiple inputs to the model ((x, y))

I’m getting this with trying to load an exported model in iOS (Using Pytorch 1.3.1):

private lazy var module: TorchModule = {
        if let filePath = Bundle.main.path(forResource: "model", ofType: "pt"),
            let module = TorchModule(fileAtPath: filePath) {
            return module
        } else {
            fatalError("Can't find the model file!")
        }
    }()

false CHECK FAILED at /Users/distiller/project/c10/core/Backend.h (tensorTypeIdToBackend at /Users/distiller/project/c10/core/Backend.h:106)

Model looks like:

import torch
from model import TDNN_LSTM

torch.set_grad_enabled(False)
model = TDNN_LSTM.load_model("model_path.pth")
model = model.to("cpu")
model = model.eval()

x = torch.rand((1, 80, 300)).to("cpu")
y = torch.IntTensor([300]).to("cpu")
traced = torch.jit.trace(model, (x, y))
traced = traced.eval().to("cpu")

traced.save("traced.pt")

Any idea what could be causing this? I confirmed that the model runs correctly on a CPU in the Python interpreter. I figured it was a problem with the model being on CUDA but I made (extra) sure to put everything on the CPU. Can upload a version of model somewhere if that would help. Thanks!

1 Like