joelpaulkoch

joelpaulkoch

Hi, I built a small cli application combining Bumblebee and Burrito you can find the repository here: GitHub - joelpaulkoch/bumbur: An example for an AI CLI application in Elixir · GitHub

You can build binaries using MIX_ENV=prod mix release, they will appear in the burrito_out directory.

You can cross compile but I’m building only the executable for the system I’m working on, so this is not a cross compilation issue.

The binary produced for macos works perfectly but I get this error for the linux executable:

19:17:06.520 [warning] The on_load function for module Elixir.EXLA.NIF returned:
{:error,
 {:load_failed,
  ~c"Failed to load NIF library: 'Error loading shared library libstdc++.so.6: No such file or directory (needed by /home/joel/.local/share/.burrito/bumbur_erts-15.0.1_0.1.0/lib/exla-0.7.3/priv/libexla.so)'"}}

Running ldd /home/joel/.local/share/.burrito/bumbur_erts-15.0.1_0.1.0/lib/exla-0.7.3/priv/libexla.so produces this output:

linux-vdso.so.1 (0x00007fd28a598000)
libxla_extension.so => /home/joel/.local/share/.burrito/bumbur_erts-15.0.1_0.1.0/lib/exla-0.7.3/priv/xla_extension/lib/libxla_extension.so (0x00007fd279e00000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fd279a00000)
libm.so.6 => /lib64/libm.so.6 (0x00007fd279d17000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fd279ce9000)
libc.so.6 => /lib64/libc.so.6 (0x00007fd279600000)
librt.so.1 => /lib64/librt.so.1 (0x00007fd28a422000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd28a41d000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fd28a418000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd28a59a000)

libstdc++.so.6 is on my system at /lib64.
So I tried running LD_LIBRARY_PATH=/lib64 burrito_out/bumbur_linux, this results in another error:

19:21:20.264 [warning] The on_load function for module Elixir.EXLA.NIF returned:
{:error,
 {:load_failed,
  ~c"Failed to load NIF library: 'Error relocating /home/joel/.local/share/.burrito/bumbur_erts-15.0.1_0.1.0/lib/exla-0.7.3/priv/libexla.so: __libc_single_threaded: symbol not found'"}}	

I’m not sure what the underlying issue is.
I believe that _build/prod/lib/exla/priv/libexla.so is copied into the Burrito build and that somehow doesn’t play nicely.
I’m not even sure if this is actually an issue of Burrito or Exla, or if I’m simply missing a flag.

What I’ve tried:

  • run LD_LIBRARY_PATH=/lib64 burrito_out/bumbur_linux
  • set nifcxx_flags: "-L/lib64" for the Burrito target (same for nifc_flags)

Burrito uses musl, I don’t know if this plays a role here.

The situation looks similar to this post which unfortunately doesn’t include a solution: Using EXLA in mix release on MacOS/Darwin fails with `Failed to load NIF library: ... libxla_extension.so...`

Any help is welcome.

Showing Posts 1 to 10

D4no0

D4no0

Can you confirm this is happening when cross-compiling both from mac/linux?

seanmor5

seanmor5

Author of Genetic Algorithms in Elixir

This is probably because Burrito uses musl. The libxla_extension.so that libexla.so uses precompiled on Linux is only precompiled against glibc. There was an Alpine/musl build a long time ago, but it was way too hard to maintain because it relied on patching TensorFlow/XLA and LLVM at the same time: Add alpine build by seanmor5 · Pull Request #31 · elixir-nx/xla · GitHub

joelpaulkoch

joelpaulkoch OP

I can cross compile successfully for both platforms on both systems.
I get this error at runtime on my linux system with the binary built on the linux system.
I’ve disabled cross compiling on the linux system, removed all caches and only built the linux binary, it’s the same result.
I didn’t try to run the linux binary built on macos.

joelpaulkoch

joelpaulkoch OP

This is my current understanding:

  • I get the precompiled libexla.so which is precompiled against glibc
  • I can run the program using mix run, this way /lib64/libstdc++.so.6 should be used (?)
  • When I build the burrito release, libexla.so is packed into the binary together with everything else
  • When I run the burrito release for the first time, everything gets unpacked into ~/.local/share/.burrito/, moreover burrito copies a runtime library to /tmp/libc-musl-[some hash].so
  • libexla.so fails to find libstdc++.so.6, it’s unchanged so /lib64 is not passed as a directory to look for shared libraries
  • When I add LD_LIBRARY_PATH=/lib64, libstdc++.so.6 is found but I still get the error __libc_single_threaded: symbol not found because now I’m running against system libraries at /lib64 and the burrito musl runtime library at /tmp at the same time

I guess possible solutions are:

  1. link everything exla related against the burrito musl runtime library
  2. build a statically linked libexla.so

Not sure if I will put any more work into this but thanks to both of you nevertheless.

D4no0

D4no0

Quick question, what architecture are you compiling against? New macs are running on ARM while your usual linux device is x86_64.

joelpaulkoch

joelpaulkoch OP

I compile on a x86_64 linux machine for a x86_64 linux machine, so I don’t think it’s related to cross compiling.

arcanemachine

arcanemachine

I had a similar issue when attempting to use an older version of Linux (RHEL 7) to build a release.

Are all your Linux deps up to date? And is your OS at EOL or is it still getting updates?

Just a shot in the dark…

joelpaulkoch

joelpaulkoch OP

Thanks, good idea, but it’s a rolling distro, so everything is up to date

dyzdyz010

dyzdyz010

Any update on this? I’m facing the exact same problem when using burrito with MDex.

Must I recompile MDex’s nif library manually using musl instead of glibc to solve this?

pieterclaerhout

pieterclaerhout

It’s a known issue they are working on…

https://github.com/leandrocp/mdex/issues/149

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews