# Caffe2 vs libtorch, realistically

**URL:** <https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526>\
**Category:** C++\
**Created:** [July 13, 2019, 3:40pm UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526 "2019-07-13T15:40:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshanab](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jshanab/32/12561_2.png) [@jshanab](https://discuss.pytorch.org/u/jshanab)\
**Post date:** [July 13, 2019, 3:40pm UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526/1 "2019-07-13T15:40:05Z")

</div>

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?  
So far:  
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.  
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)  
3) I am trying to find a c++ **cross platform** 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.)

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.

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 ☹

---

<div class="post-metadata">

**Author:** ![tom](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/tom/32/3162_2.png) [@tom](https://discuss.pytorch.org/u/tom)\
**Post date:** [July 13, 2019, 5:42pm UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526/2 "2019-07-13T17:42:13Z")

</div>

A few weeks ago, @dambo 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:

> [@Message to admins](https://discuss.pytorch.org/t/message-to-admins/48153):
>
> 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…

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.

Best regards

Thomas

---

<div class="post-metadata">

**Author:** ![jshanab](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jshanab/32/12561_2.png) [@jshanab](https://discuss.pytorch.org/u/jshanab)\
**Post date:** [July 13, 2019, 6:00pm UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526/3 "2019-07-13T18:00:11Z")

</div>

I did find that post AFTER my posting and cannot agree more. it APPEARS like …

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.

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.

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.

```
                  Has (recent)c++ prebuilts | C++ buildable | Handle PreBuilt Models | HW Acceleration |

```

MXNET NO | Not So Far | Yes | Fastest Cuda impl |  
TensorFlow NO | Not since change to bazel | The pgm is the model | Slower |  
CNTK ?  
caffe2 Yes | Yes | Yes lots of them | yes |  
libtorch Yes | Yes | Only TorchScript | Yes |

and non-cuda  
OpenVino Yes | Yes | Yes lots | Yes, Intel only |

Am I wrong about any of this assessment?

Forgive me “SLA” ???  
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.

---

<div class="post-metadata">

**Author:** ![smth](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/smth/32/13_2.png) [@smth](https://discuss.pytorch.org/u/smth)\
**Post date:** [July 14, 2019, 4:09pm UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526/4 "2019-07-14T16:09:23Z")

</div>

the caffe2 bits have no public support, and will be changed and deprecated at will.

libtorch will be maintained, supported and improved, but at this point it wont have feature parity with caffe2 as a goal.

---

<div class="post-metadata">

**Author:** ![dambo](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dambo/32/29088_2.png) [@dambo](https://discuss.pytorch.org/u/dambo)\
**Post date:** [July 16, 2019, 8:17am UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526/5 "2019-07-16T08:17:10Z")

</div>

Hi,  
Thanks for your reply.  
What is the FB’s long term strategy regarding the deployment of PyTorch models for production?  
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.

Regards,

---

<div class="post-metadata">

**Author:** ![smth](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/smth/32/13_2.png) [@smth](https://discuss.pytorch.org/u/smth)\
**Post date:** [July 18, 2019, 6:59am UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526/6 "2019-07-18T06:59:20Z")

</div>

we deploy PyTorch models in production via libtorch at scale.  
We are investing in this heavily via `torch.jit`.

There are several tutorials covering “export to C+±only runtime”, including  
[https://pytorch.org/tutorials/advanced/cpp\_export.html](https://pytorch.org/tutorials/advanced/cpp_export.html) and [https://pytorch.org/tutorials/beginner/deploy\_seq2seq\_hybrid\_frontend\_tutorial.html](https://pytorch.org/tutorials/beginner/deploy_seq2seq_hybrid_frontend_tutorial.html)

---

<div class="post-metadata">

**Author:** ![dongfangduoshou123](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dongfangduoshou123/32/14375_2.png) [@dongfangduoshou123](https://discuss.pytorch.org/u/dongfangduoshou123)\
**Post date:** [July 25, 2019, 7:12am UTC](https://discuss.pytorch.org/t/caffe2-vs-libtorch-realistically/50526/7 "2019-07-25T07:12:27Z")

</div>

But I see the pytorch’s caffe2 sub folder on github is still updating recently, this is why, thank you!
