rodrigodzf / bela-torch

The Unlicense
9 stars 0 forks source link

Installing on Bela #1

Open peacheym opened 2 years ago

peacheym commented 2 years ago

Good morning! Thanks a ton for providing this resource. I've been trying to install libtorch on the Bela architecture since January, but have continually ran into road bumps along the way (I was attempting to build & install it directly on the Beaglebone).

I am fairly new to cross compiling, and so I'm hoping you can provide a bit of additional guidance for finishing the install process. I was able to run your dockerfile with no issue, and after ~ 8 hours have the pytorch-install/pytorch-install.tar.gz file. I copied that over to the /root directory of the Bela and unzipped it, but not 100% sure where to go next.

The Bela folks authored this post for using external libraries which I've used successfully in the past, but not with a cross compiled library.

This could be something super simple, but either way I would love to hear your thoughts. Thanks! 😄

rodrigodzf commented 2 years ago

Hi! so this repository only serves to provide torchlib. If you want to use it, you have several alternatives. I personally recommend using the CMake module included in the pytorch-install folder. For example:

if(ENABLE_PYTORCH)
    add_compile_definitions(ENABLE_PYTORCH)
    # find pytorch
    list(APPEND CMAKE_PREFIX_PATH /yourpath/pytorch-install)
    find_package(Torch REQUIRED)
endif()

and then for your app:

if (ENABLE_PYTORCH)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
    target_link_libraries(${MY_APP} PUBLIC ${TORCH_LIBRARIES})
endif()

You can check how I used it in the dev branch of this repo:

https://github.com/rodrigodzf/DeepLearningForBela/blob/dev/DL4Bela/lib/NNLib/CMakeLists.txt

Because people use different build systems there will be no instructions here, but I will add better instructions in the other repo.

peacheym commented 2 years ago

Thanks for the prompt reply! I'll take a look at the branch you mentioned and see what I can figure out. 😃