Error when building executorch on libquantized

username: Giustiniano
cooked: <p>Hello,</p>
<p>I am trying to follow <a href="https://github.com/pytorch/executorch/blob/main/examples/models/llama2/README.md#step-1-setup" rel="noopener nofollow ugc">the instructions</a> to run llama3-instruct with executorch, but I am encountering an error when running <code>install_requirements.sh --pybind xnnpack</code><br>
It seems that it fails to build <code>kernels/quantized/libquantized_ops_aot_lib.so</code> so it cannot link it.<br>
Unfortunately, the script only reports the error, but does not say much as to why.<br>
I am running Ubuntu 22.04 on Azure</p>
<p>I tried to run this on a local ubuntu 22.04 running with hyper-v and it works, but then I don’t have enough RAM to export the model</p>
<p>Please let me know if you need any further information, thanks</p>
<pre><code class="lang-auto"> [ 88%] Building CXX object kernels/quantized/CMakeFiles/quantized_ops_aot_lib.dir/cpu/op_quantize.cpp.o
  [ 88%] Building CXX object kernels/quantized/CMakeFiles/quantized_ops_aot_lib.dir/__/portable/cpu/util/reduce_util.cpp.o
  [ 88%] Building CXX object kernels/quantized/CMakeFiles/quantized_ops_aot_lib.dir/__/__/runtime/core/exec_aten/util/tensor_util_aten.cpp.o
  [ 88%] Linking CXX shared library libquantized_ops_aot_lib.so
  /usr/bin/ld: cannot find dynamic_lookup: No such file or directory
  collect2: error: ld returned 1 exit status
  gmake[3]: *** [kernels/quantized/CMakeFiles/quantized_ops_aot_lib.dir/build.make:391: kernels/quantized/libquantized_ops_aot_lib.so] Error 1
</code></pre>

username: ptrblck
cooked: <p>Do you see any other error messages further up in the logs?</p>

username: Giustiniano
cooked: <p>I can see the following warnings, don’t know if they are relevant</p>
<pre><code class="lang-auto">[ 44%] Building C object backends/xnnpack/third-party/XNNPACK/CMakeFiles/microkernels-prod.dir/src/amalgam/gen/avx512vnnigfni.c.o
  In file included from /home/enrico/executorch/executorch/../executorch/runtime/platform/assert.h:13,
                   from /home/enrico/executorch/executorch/../executorch/runtime/core/array_ref.h:32,
                   from /home/enrico/executorch/executorch/../executorch/runtime/core/exec_aten/exec_aten.h:32,
                   from /home/enrico/executorch/executorch/../executorch/extension/aten_util/aten_bridge.h:11,
                   from /home/enrico/executorch/executorch/extension/aten_util/aten_bridge.cpp:9:
  /home/enrico/executorch/executorch/extension/aten_util/aten_bridge.cpp: In function ‘void torch::util::{anonymous}::check_tensor_meta(const at::Tensor&amp;, const Tensor&amp;)’:
  /home/enrico/executorch/executorch/../executorch/runtime/platform/assert.h:24:7: warning: format ‘%hhd’ expects argument of type ‘int’, but argument 9 has type ‘torch::executor::ScalarType’ [-Wformat=]
     24 |       "In function %s(), assert failed" _format, \
  /home/enrico/executorch/executorch/../executorch/runtime/platform/log.h:161:11: note: in definition of macro ‘ET_LOG’
    161 |           _format,                                                            \
        |           ^~~~~~~
  /home/enrico/executorch/executorch/../executorch/runtime/platform/assert.h:39:7: note: in expansion of macro ‘ET_ASSERT_MESSAGE_EMIT’
     39 |       ET_ASSERT_MESSAGE_EMIT(" (%s): " _format, #_cond, ##__VA_ARGS__); \
        |       ^~~~~~~~~~~~~~~~~~~~~~
  /home/enrico/executorch/executorch/extension/aten_util/aten_bridge.cpp:57:3: note: in expansion of macro ‘ET_CHECK_MSG’
     57 |   ET_CHECK_MSG(
        |   ^~~~~~~~~~~~
  /home/enrico/executorch/executorch/extension/aten_util/aten_bridge.cpp:59:31: note: format string is defined here
     59 |       "dtypes dont match a %hhd vs. b %hhd",
        |                            ~~~^
        |                               |
        |                               int
  In file included from /home/enrico/executorch/executorch/../executorch/runtime/platform/assert.h:13,
                   from /home/enrico/executorch/executorch/../executorch/runtime/core/array_ref.h:32,
                   from /home/enrico/executorch/executorch/../executorch/runtime/core/exec_aten/exec_aten.h:32,
                   from /home/enrico/executorch/executorch/../executorch/extension/aten_util/aten_bridge.h:11,
                   from /home/enrico/executorch/executorch/extension/aten_util/aten_bridge.cpp:9:
  /home/enrico/executorch/executorch/../executorch/runtime/platform/assert.h:24:7: warning: format ‘%hhd’ expects argument of type ‘int’, but argument 10 has type ‘torch::executor::ScalarType’ [-Wformat=]
     24 |       "In function %s(), assert failed" _format, \
  /home/enrico/executorch/executorch/../executorch/runtime/platform/log.h:161:11: note: in definition of macro ‘ET_LOG’
    161 |           _format,                                                            \
        |           ^~~~~~~
  /home/enrico/executorch/executorch/../executorch/runtime/platform/assert.h:39:7: note: in expansion of macro ‘ET_ASSERT_MESSAGE_EMIT’
     39 |       ET_ASSERT_MESSAGE_EMIT(" (%s): " _format, #_cond, ##__VA_ARGS__); \
        |       ^~~~~~~~~~~~~~~~~~~~~~
  /home/enrico/executorch/executorch/extension/aten_util/aten_bridge.cpp:57:3: note: in expansion of macro ‘ET_CHECK_MSG’
     57 |   ET_CHECK_MSG(
        |   ^~~~~~~~~~~~
  /home/enrico/executorch/executorch/extension/aten_util/aten_bridge.cpp:59:42: note: format string is defined here
     59 |       "dtypes dont match a %hhd vs. b %hhd",
        |                                       ~~~^
        |                                          |
        |                                          int
</code></pre>
<p>and</p>
<pre><code class="lang-auto"> [ 55%] Building CXX object kernels/portable/CMakeFiles/portable_kernels.dir/cpu/op_amin.cpp.o
  /home/enrico/executorch/executorch/util/read_file.cpp: In function ‘torch::executor::Error torch::executor::util::read_file_content(const char*, std::shared_ptr&lt;char&gt;*, size_t*)’:
  /home/enrico/executorch/executorch/util/read_file.cpp:49:8: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
     49 |   fread(ptr.get(), fileLen, 1, file);
        |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</code></pre>
<p>and</p>
<pre><code class="lang-auto"> [ 55%] Building CXX object extension/data_loader/CMakeFiles/extension_data_loader.dir/mmap_data_loader.cpp.o
  In file included from /home/enrico/executorch/executorch/extension/data_loader/../../../executorch/runtime/core/error.h:18,
                   from /home/enrico/executorch/executorch/extension/data_loader/../../../executorch/runtime/core/result.h:19,
                   from /home/enrico/executorch/executorch/extension/data_loader/../../../executorch/runtime/core/data_loader.h:14,
                   from /home/enrico/executorch/executorch/extension/data_loader/../../../executorch/extension/data_loader/mmap_data_loader.h:11,
                   from /home/enrico/executorch/executorch/extension/data_loader/mmap_data_loader.cpp:9:
  /home/enrico/executorch/executorch/extension/data_loader/mmap_data_loader.cpp: In function ‘void torch::executor::util::{anonymous}::MunmapSegment(void*, void*, size_t)’:
  /home/enrico/executorch/executorch/extension/data_loader/mmap_data_loader.cpp:140:9: warning: too many arguments for format [-Wformat-extra-args]
    140 |         "munmap(0x%zx, %zu) failed: %s (ignored)",
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /home/enrico/executorch/executorch/extension/data_loader/../../../executorch/runtime/platform/log.h:161:11: note: in definition of macro ‘ET_LOG’
    161 |           _format,                                                            \
        |           ^~~~~~~
</code></pre>

username: ptrblck
cooked: <p>No, warnings won’t let the code fail.</p>

username: vjml
cooked: <p>I get the same error as the original poster. I do get cmake deprecation warnings in the logs, but no errors before this linking error.</p>
<p>[ 90%] Built target portable_kernels<br>
[ 90%] Generating selected_operators.yaml for portable_ops_lib<br>
[ 90%] Linking CXX shared library libquantized_ops_aot_lib.so<br>
c++: error: dynamic_lookup: No such file or directory<br>
make[3]: *** [kernels/quantized/CMakeFiles/quantized_ops_aot_lib.dir/build.make:391: kernels/quantized/libquantized_ops_aot_lib.so] Error 1<br>
make[2]: *** [CMakeFiles/Makefile2:1080: kernels/quantized/CMakeFiles/quantized_ops_aot_lib.dir/all] Error 2<br>
make[2]: *** Waiting for unfinished jobs…<br>
[100%] Generating code for kernel registration<br>
[100%] Building CXX object kernels/portable/CMakeFiles/portable_ops_lib.dir/portable_ops_lib/RegisterCodegenUnboxedKernelsEverything.cpp.o<br>
[100%] Linking CXX static library libportable_ops_lib.a<br>
[100%] Built target portable_ops_lib<br>
make[1]: *** [CMakeFiles/Makefile2:733: CMakeFiles/portable_lib.dir/rule] Error 2<br>
make: *** [Makefile:234: portable_lib] Error 2<br>
error: command ‘/home/xxxx/miniconda3/envs/executorch_llama/bin/cmake’ failed with exit code 2<br>
error: subprocess-exited-with-error</p>
<p>× Building wheel for executorch (pyproject.toml) did not run successfully.<br>
│ exit code: 1<br>
╰─&gt; See above for output.</p>
<p>note: This error originates from a subprocess, and is likely not a problem with pip.</p>

username: ptrblck
cooked: <p>You would also need to check for previous errors pointing to a failure related to <code>dynamic_lookup</code>. If you have trouble isolating it, feel free to upload the full log into e.g. a Gist.</p>

username: Giustiniano
cooked: <p>This is the full log, including the apt get calls so you can see the version of everything that is installed, in case it helps</p>
<aside class="onebox githubgist" data-onebox-src="https://gist.github.com/Giustiniano/d1fdbc3b089e0067193663aec2551c7e">
  <header class="source">

      <a href="https://gist.github.com/Giustiniano/d1fdbc3b089e0067193663aec2551c7e" target="_blank" rel="noopener nofollow ugc">gist.github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gist.github.com/Giustiniano/d1fdbc3b089e0067193663aec2551c7e" target="_blank" rel="noopener nofollow ugc">https://gist.github.com/Giustiniano/d1fdbc3b089e0067193663aec2551c7e</a></h4>

  <h5>log.txt</h5>
  <pre><code class="Text">Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 6.5.0-1023-azure x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Fri Jul 12 04:36:52 UTC 2024

  System load:  0.45              Processes:             193
  Usage of /:   2.4% of 61.84GB   Users logged in:       0</code></pre>
   This file has been truncated. <a href="https://gist.github.com/Giustiniano/d1fdbc3b089e0067193663aec2551c7e" target="_blank" rel="noopener nofollow ugc">show original</a>

<p>
</p>

  </article>

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

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


username: ptrblck
cooked: <p>Your log does not show your original error and fails with:</p>
<pre data-code-wrap="python"><code class="lang-python">CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".
</code></pre>
<p>pointing to potentially <a href="https://stackoverflow.com/questions/48160125/cmake-was-unable-to-find-a-build-program-corresponding-to-unix-makefiles">this issue</a>.</p>
<p>Make sure you are able to at least start the build in your environment.</p>

username: Giustiniano
cooked: <p>Apologies, I did forget to install cmake the first time, this is the log after I installed it</p><aside class="onebox githubgist" data-onebox-src="https://gist.github.com/Giustiniano/2c4c3c90957b70fcba6cc1f077e62059">
  <header class="source">

      <a href="https://gist.github.com/Giustiniano/2c4c3c90957b70fcba6cc1f077e62059" target="_blank" rel="noopener nofollow ugc">gist.github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://gist.github.com/Giustiniano/2c4c3c90957b70fcba6cc1f077e62059" target="_blank" rel="noopener nofollow ugc">https://gist.github.com/Giustiniano/2c4c3c90957b70fcba6cc1f077e62059</a></h4>

  <h5>log.txt</h5>
  <pre><code class="Text">(venv) enrico@executorch:~/executorch/executorch$ ./install_requirements.sh --pybind xnnpack
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/nightly/cpu
Requirement already satisfied: torch==2.5.0.dev20240618 in /home/enrico/executorch/venv/lib/python3.10/site-packages (2.5.0.dev20240618+cpu)
Requirement already satisfied: torchvision==0.20.0.dev20240618 in /home/enrico/executorch/venv/lib/python3.10/site-packages (0.20.0.dev20240618+cpu)
Requirement already satisfied: cmake in /home/enrico/executorch/venv/lib/python3.10/site-packages (3.30.0)
Requirement already satisfied: pip&gt;=23 in /home/enrico/executorch/venv/lib/python3.10/site-packages (24.1.2)
Requirement already satisfied: pyyaml in /home/enrico/executorch/venv/lib/python3.10/site-packages (6.0.1)
Requirement already satisfied: setuptools&gt;=63 in /home/enrico/executorch/venv/lib/python3.10/site-packages (70.3.0)
Requirement already satisfied: tomli in /home/enrico/executorch/venv/lib/python3.10/site-packages (2.0.1)
Requirement already satisfied: wheel in /home/enrico/executorch/venv/lib/python3.10/site-packages (0.43.0)</code></pre>
   This file has been truncated. <a href="https://gist.github.com/Giustiniano/2c4c3c90957b70fcba6cc1f077e62059" target="_blank" rel="noopener nofollow ugc">show original</a>

<p>
</p>

  </article>

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

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


username: ptrblck
cooked: <p><code>flatcc</code> fails with a missing file:</p>
<pre><code class="lang-auto">  /bin/sh: 1: /home/enrico/executorch/executorch/sdk/../third-party/flatcc/bin/flatcc: not found
  gmake[3]: *** [sdk/CMakeFiles/etdump_schema.dir/build.make:71: sdk/include/executorch/sdk/etdump/etdump_schema_flatcc_reader.h] Error 127
  gmake[2]: *** [CMakeFiles/Makefile2:1974: sdk/CMakeFiles/etdump_schema.dir/all] Error 2
</code></pre>
<p>Indeed I do not see <code>executorch/sdk/etdump/etdump_schema_flatcc_reader.h</code> in the current <code>main</code> branch of <a href="https://github.com/pytorch/executorch/tree/f9efb0521a867d02e4bf828954d10a1bfb7737a6/sdk/etdump"><code>executorch</code></a> so you might want to open an isue in their GitHub repository asking if this file is missing by mistake.</p>