Caffe2 vs libtorch, realistically

username: jshanab
cooked: <p>I found some mostly unanswered questions in this forum that are months old and I just cannot get a good handle on the libtorch concept. Is libtorch going to get all the functionality of caffe2 eventually and then the deprecation will happen?<br>
So far:<br>
1) libtorch introduces yet another Intermediate representation with no way to load onnx or other pretrained models or convert,  other than a multi-stage conversion walking it thru python.<br>
2) The now similar name means you CANNOT search for c++ API topics without being inundated with python only responses. Also there seems to be Torch the Lua based to show up in searches also. (Searches outside this and linking back to this forum too)<br>
3) I am trying to find a c++ <strong>cross platform</strong> inference library/framework. I am interested in using pre-trained models from c++ in desktop and embedded environments and so learning has been done/is to be done in a bigger more capable workstation. It is very difficult to wade thru the Python-Centric Data scientist learning side and tease out the C++ production side. (On a plus side mxnet, tensorflow do not have prebuilts for windows and after 40+ hours of attempting to build them… I know why.)</p>
<p>So the question still stands, Is libtorch going to be a scaled down interface or is there a realistic effort to keep C++ a 1st class citizen like it was/is in caffe2.</p>
<p>Said another way, Can I still use the caffe2 features and models on the assumption that libtorch will have an equivalent before deprecation? or would that be shooting myself in the foot <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=9" title=":frowning:" class="emoji" alt=":frowning:"></p>

username: tom
cooked: <p>A few weeks ago, <a class="mention" href="/u/dambo">@dambo</a> had a reasonably constructive take on concerns that seem to overlap yours and got quite a few responses including from some of the PyTorch/libtorch devs:</p>
<aside class="quote quote-modified" data-post="1" data-topic="48153">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dambo/48/29088_2.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/message-to-admins/48153">Message to admins</a> <a class="badge-category__wrapper " href="/c/c/11"><span data-category-id="11" data-drop-close="true" class="badge-category " title="Topics related to the C++ Frontend, C++ API or C++ Extensions"><span class="badge-category__name">C++</span></span></a>
  </div>
  <blockquote>
    Hello, 
Being one of the early adopters and advocated of PyTorch, I have the strange feeling that Libtorch is, to some extent neglected. This is evident in the level of activity and chatter in the C++ sub-forum. 
I find that it is very hard to get answers to the simplest questions, such as: how to work in batches during inference / and or training for ImageNet like datasets? How to utilise multiple GPU’s during training and inference of traced modules? Where can I find an example for loading  an…
  </blockquote>
</aside>

<p>I would only recommend using libtorch if it sparks joy. Given the concerns you listed and your dissatisfaction with the naming, maybe a framework with a stronger branded name that offers commercial support with some sort service level agreement would serve your needs best.</p>
<p>Best regards</p>
<p>Thomas</p>

username: jshanab
cooked: <p>I did find that post AFTER my posting and cannot agree more. it APPEARS like …</p>
<p>The fundamental question, for me is still not answered. Is this deprecation the death of caffe2 or not? Is the migration path going to happen gracefully or rudely.</p>
<p>I do not know if the C++ used in PyTorch is completely different than caffe2 or from a common ancestor. I know it said it was “merging”. So architectural details may be helpful.</p>
<p>After my initial test with python on 5 or 6 different frameworks it was really a slap in the face to find how poorly c++ is supported. So far caffe2 looks best but then the red flag goes up on “Deprecation” and “Merging” and what that exactly means.</p>
<pre><code>                  Has (recent)c++ prebuilts |  C++ buildable |   Handle PreBuilt Models |      HW Acceleration  |
</code></pre>
<p>MXNET                NO                               |  Not So Far      |        Yes                           |    Fastest Cuda  impl |<br>
TensorFlow         NO                               | Not since change to bazel | The pgm is the model | Slower |<br>
CNTK                    ?<br>
caffe2                  Yes                              | Yes                   |   Yes lots of them               | yes |<br>
libtorch                Yes                              | Yes                   |  Only TorchScript  |  Yes |</p>
<p>and non-cuda<br>
OpenVino            Yes                              | Yes                   | Yes lots  | Yes, Intel only               |</p>
<p>Am I wrong about any of this assessment?</p>
<p>Forgive me “SLA” ???<br>
Naming is trivail, just wanted to point out how that can contribute to the impression of poor c++ support, gets washed out by the plethera of python info.</p>

username: smth
cooked: <p>the caffe2 bits have no public support, and will be changed and deprecated at will.</p>
<p>libtorch will be maintained, supported and improved, but at this point it wont have feature parity with caffe2 as a goal.</p>

username: dambo
cooked: <p>Hi,<br>
Thanks for your reply.<br>
What is the FB’s long term strategy regarding the deployment of PyTorch models for production?<br>
In some cases, I can not fathom using Python for run-time inference (even though this is my/others adopted strategy) and would love to know C++ is indeed on the table for such circumstances wherein Python is not applicable.</p>
<p>Regards,</p>

username: smth
cooked: <p>we deploy PyTorch models in production via libtorch at scale.<br>
We are investing in this heavily via <code>torch.jit</code>.</p>
<p>There are several tutorials covering “export to C+±only runtime”, including<br>
<a href="https://pytorch.org/tutorials/advanced/cpp_export.html" rel="nofollow noopener">https://pytorch.org/tutorials/advanced/cpp_export.html</a> and <a href="https://pytorch.org/tutorials/beginner/deploy_seq2seq_hybrid_frontend_tutorial.html" rel="nofollow noopener">https://pytorch.org/tutorials/beginner/deploy_seq2seq_hybrid_frontend_tutorial.html</a></p>

username: dongfangduoshou123
cooked: <p>But I see the pytorch’s caffe2 sub folder on github is still updating recently, this is why, thank you!</p>