Cross-compiling for ARM and other archs

wny: <p>I have been able to build my own custom model-runner based on the glow-provided model-runner and image-classifier (refer to <a href="https://discuss.pytorch.org/t/glow-with-generic-model-builder/42559" class="inline-onebox">Glow with generic model builder</a>). 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).</p>
<p>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.</p>
<p>I am focusing only on the cpu backend for now.</p>
<p>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?</p>
<p>Any pointers would be appreciated.</p>

wny: <p>Ah, never mind! There is the <code>-target</code> option that seems to be the same as the default LLVM option.</p>

atomic: <p>Hello <a class="mention" href="/u/wny">@wny</a>,</p>
<p>Could you explain in more details how could I cross-compile Glow for aarch64 with -target option?</p>
<p>I have added it in CMakeLists.txt as:</p>
<pre><code class="lang-auto">set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -target=aarch64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target=aarch64")
</code></pre>
<p>But it seems to fail during command: <code>cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ../glow</code> with the following error:</p>
<pre><code class="lang-auto">-- 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".
</code></pre>
<p>Thank you in advance!</p>

jfix: <p>You want to use <code>-target</code> when you run e.g. <code>image-classifier</code> or <code>model-compiler</code>, 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. <code>-target</code> should not be used as a CMake flag – you still want to build Glow itself for your local machine’s architecture.</p>

Jesse_Stone: <p>full build step cross compile on arm64 try</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://fatalfeel.blogspot.com/2013/12/libtorch-cross-compile-on-aarch64-linux.html">
  <header class="source">
      <img src="https://fatalfeel.blogspot.com/favicon.ico" class="site-icon" width="32" height="32">

      <a href="https://fatalfeel.blogspot.com/2013/12/libtorch-cross-compile-on-aarch64-linux.html" target="_blank" rel="noopener nofollow ugc">fatalfeel.blogspot.com</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://fatalfeel.blogspot.com/2013/12/libtorch-cross-compile-on-aarch64-linux.html" target="_blank" rel="noopener nofollow ugc">libtorch cross compile on aarch64-linux-gnu-gcc include backward</a></h3>

  <p> Refer to: https://github.com/pytorch/pytorch#get-the-pytorch-source https://github.com/pytorch/pytorch/blob/master/docs/libtorch.rst https:...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>