shyney7
(Marcel)
May 13, 2020, 12:52pm
10
@glaringlee
Thank you so much for replying and trying to help! I really appreciate this!
This is also what I found in another repo on github while searching the web for similar errors.
So I have changed the CMakelists.txt file as follows:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -stdlib=libstdc++ ${TORCH_CXX_FLAGS}")
But now I’m getting the following compiler errors:
I have also opened an issue on github describing everything and with all the files from a repo I created.
opened 09:12AM - 12 May 20 UTC
module: build
module: cpp
triaged
I am currently trying to implement the Pytorch C++ API into production. RTOS are… indispensable in production environments so I'm trying to cross-compile with cmake for QNX Neutrino 7.0.0 (x86_64).
However, when compiling a simple test program (empty main() function just including "#include <torch/torch.h>")
I get the following compiler errors:
https://github.com/shyney7/libtorch-cross-RTOS-test/blob/master/Compilerlogs/comperr-without-stdlib-flag.md
I had to set the following command so that cmake finds the torch library in the host path.
` SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)`
This is how my **cmake Toolchain File** looks like:
https://github.com/shyney7/libtorch-cross-RTOS-test/blob/master/cmake/qnx_7.0.0_linux_x86_64.cmake
This is my **CMakeLists.txt** file:
https://github.com/shyney7/libtorch-cross-RTOS-test/blob/master/CMakeLists.txt
Unfortunately I am not a computer scientist but a mechanical engineer working at a research lab of a german university trying to implement libtorch into production. So I am not sure what the compiler errors mean. Thats why I searched the web for similar errors and found an issue of another repo here:
https://github.com/eProsima/Fast-RTPS/issues/300
There it is mentioned that it is also needed to prevent the qcc compiler from using the LLVM Compiler Infrastructure from v1/memory by using the `-stdlib=libstdc++` flag.
I also tried this by changing my CMakeLists.txt file to use the following flags:
`set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -stdlib=libstdc++ ${TORCH_CXX_FLAGS}")`
But then I'm getting the following **compiler errors**:
https://github.com/shyney7/libtorch-cross-RTOS-test/blob/master/Compilerlogs/comperr_with-stdlib%3Dlibstdc%2B%2B_flag.md
In the announcement videos where Libtorch and the C++ API were introduced, it was always said that the C++ API is specifically for production environments. The fact is that in production environments you mostly work with real-time operating systems like QNX or FreeRTOS, so I'm sure that there is somehow a way to get libtorch working on QNX.
Here is the repo with all the files:
https://github.com/shyney7/libtorch-cross-RTOS-test
Here is also a link to my first post on the discussion forums where I faced some issues with setting up the cmake toolchain file correctly:
https://discuss.pytorch.org/t/cross-compiling-with-cmake-for-embedded-systems-qnx/79681
## Environment
- Libtorch Version : 1.5 Release
- OS : cross-compiling on Ubuntu 18.04 (VM) for **QNX 7.0.0 (x84_64)**
- How you installed PyTorch : libtorch 1.5 zip from pytorch.org (for linux tried with both Pre & cxx11 ABI)
- Build command you used :
`cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/qnx_7.0.0_linux_x86_64.cmake ..`
`make`
- GNU version: 5.4.0
- CUDA/cuDNN version: none
- GPU models and configuration: none
- cmake version: 3.10.2
cc @malfet @yf225 @glaringlee
I’ve tried this by moving the libtorch folder to the QNX Target Environment as stated here (QNX Docs ):
/home/marcel/qnx700/target/qnx7/x86_64/lib/libtorch/
And changed the line in the CMakelists.txt as follows:
list(APPEND CMAKE_PREFIX_PATH "${QNX_TARGET}/x86_64/lib/libtorch")
But this change did not lead to a succesful build and I’m getting the same compiler errors as shown above.
Compiler Errors