I want to build a DNN model that I will later integrate into a C++ program.

I heard that PyTorch model is hard to load it on C++ and the integration requires extra code, and it's complicated.

I have searched a bit on the internet and I have found this post: Loading a PyTorch Model in C++. I am still unsure whether or not I will have any problems in practice if I opt for PyTorch.


PyTorch now has a C++ frontend. I haven't tried it, but I'm sure you could use that.

Another option, which is more production-tested, is using a message passing framework such as ZeroMQ to communicate requests and results between Python and C++ executables.

  • $\begingroup$ first thank you for you answer. ZeroMQ serve as intermediate btw C++ and python now what if we wanna call directly the model from C++ code what i want to say is like to import it us script that will be used directly with C++ without any intermediate btw. In this case how should we process? Have you understood me ? $\endgroup$ – DINA TAKLIT Feb 26 '19 at 16:23
  • $\begingroup$ You'd have to use the PyTorch C++ frontend for that. There's a tutorial on how to do it here. $\endgroup$ – Omegastick Feb 27 '19 at 1:25
  • $\begingroup$ I have read carefully that tuto but you know this is the only doc that show how and their is lack ex that show how to do this load not only i have seen those who get some error in the process they could not get response, that means this option is not really covered. I need to look more. $\endgroup$ – DINA TAKLIT Feb 27 '19 at 5:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.