Documentation/examples of building LibTorch with make, not cmake

Hey all, sorry if this has already been covered, I tried googling/searching the forums but couldn’t find any relevant results.

I’m looking at integrating a model into a JUCE project, which uses a tool called the Projucer as the build system. The most analogous tool in terms of syntax etc would plain old Makefiles, and I was wondering if anyone knew of any examples or documentation of Make being used to build LibTorch, which in turn I could use to translate to a Projucer project.

The documentation denotes this on CMake:

The LibTorch distribution encompasses a collection of shared libraries, header files and CMake build configuration files. While CMake is not a requirement for depending on LibTorch, it is the recommended approach and will be well supported into the future.

Thanks for reading!

For building LibTorch with make, no, and I’d think you’d see limited interest in supporting building libtorch without cmake.

Now, using a prebuilt libtorch in other programs is pretty straightforward even without CMake, I have written a trivial C++ program running a model on an image and displaying (the sample program shown on my slides https://lernapparat.de/pytorch-jit-android/) and compiled that with

g++ run.cpp -I /usr/local/lib/python3.6/dist-packages/torch/lib/include/  -L /usr/local/lib/python3.6/dist-packages/torch/lib/ -ltorch -lcaffe2 -lc10 -lpthread -lX11

(where the pthread possibly and X11certainly are CImg dependencies rather than those of PyTorch).

Best regards

Thomas

1 Like

I’m using libtorch inside anaconda. Maybe my makefile gives you some hints https://github.com/ShigekiKarita/libtorch-cxx-examples/blob/master/mnist/Makefile

1 Like

How to use the libtorch https://download.pytorch.org/libtorch/nightly/cu92/libtorch-win-shared-with-deps-latest.zip using make?
Thanks.

How you solve the problem, please help me out, thanks.
Bests,
Edward.

How to build libtorch with cuda? How to write the makefile? Thanks.

I was able to integrate the model with JUCE project. Using traced model for C++.