Cross-compiling for ARM and other archs

I have been able to build my own custom model-runner based on the glow-provided model-runner and image-classifier (refer to Glow with generic model builder). Using the custom builder, I am able to output a bundle. I am also able to use the bundle to run the custom network (built a custom runner based on ResNet50 example).

My question now is: is it possible to cross-build for ARM and other architectures, or must I build on the target? In general, it looks like we should be able to build for anything that LLVM supports, but I certainly do not want to build on the target.

I am focusing only on the cpu backend for now.

The more precise question can be phrased as follows. I understand that the *.weights file is just a binary weights file, so we should be able to load it on any architecture. How can we make sure that the *.o bundle file is compatible with the target architecture? How can we direct the builder to compile it for a specific target?

Any pointers would be appreciated.

1 Like

Ah, never mind! There is the -target option that seems to be the same as the default LLVM option.

2 Likes

Hello @wny,

Could you explain in more details how could I cross-compile Glow for aarch64 with -target option?

I have added it in CMakeLists.txt as:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target=aarch64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target=aarch64")

But it seems to fail during command: cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ../glow with the following error:

-- Cannot find glog automatically. Using legacy find.
-- Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
-- Using 64b tensor dimensions.
-- Libjit option 'fast-math' enabled.
-- Found LLVM 8.0.0
-- Using LLVMConfig.cmake in: /usr/lib/llvm-8/cmake
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.10/Modules/FindThreads.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  thirdparty/folly/CMakeLists.txt:101 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/osboxes/Desktop/glow_Release/CMakeFiles/CMakeOutput.log".
See also "/home/osboxes/Desktop/glow_Release/CMakeFiles/CMakeError.log".

Thank you in advance!

You want to use -target when you run e.g. image-classifier or model-compiler, etc., which are the tools that can be used to create the binary you’re going to deploy to another machine with a different CPU architecture. -target should not be used as a CMake flag – you still want to build Glow itself for your local machine’s architecture.

full build step cross compile on arm64 try