EXLA.NIF.start_log_sink/1 Issue - Works on Ubuntu but not on MacBook M2

I’ve encountered an issue with EXLA when trying to run it on my MacBook with the M2 chip. While my application works flawlessly on an Ubuntu computer, it runs into problems on my MacBook due to an issue related to EXLA.NIF.start_log_sink/1. The error suggests that the EXLA.NIF module hasn’t been compiled properly or is unavailable.

Error:
** (Mix) Could not start application exla: EXLA.Application.start(:normal, ) returned an error: shutdown: failed to start child: EXLA.Logger
** (EXIT) an exception was raised:
** (UndefinedFunctionError) function EXLA.NIF.start_log_sink/1 is undefined (module EXLA.NIF is not available)
(exla 0.6.0) EXLA.NIF.start_log_sink(#PID<0.430.0>)
(exla 0.6.0) lib/exla/logger.ex:12: EXLA.Logger.init/1
(stdlib 5.0.2) gen_server.erl:962: :gen_server.init_it/2
(stdlib 5.0.2) gen_server.erl:917: :gen_server.init_it/6
(stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

I’m running this inside a Docker container based on the Elixir:latest image. Despite the environment being containerized, there seems to be a difference in behavior between the MacBook M2 and the Ubuntu machine. If needed, I can share the Dockerfile or any other relevant configuration.

UPDATE:
I fixed the error updating gcc.
But know i have the following error:
[info] TfrtCpuClient created.
‘+fp-armv8’ is not a recognized feature for this target (ignoring feature)
‘+lse’ is not a recognized feature for this target (ignoring feature)
‘+neon’ is not a recognized feature for this target (ignoring feature)
‘+crc’ is not a recognized feature for this target (ignoring feature)
‘+crypto’ is not a recognized feature for this target (ignoring feature)
‘+fp-armv8’ is not a recognized feature for this target (ignoring feature)
‘+lse’ is not a recognized feature for this target (ignoring feature)
‘+neon’ is not a recognized feature for this target (ignoring feature)
‘+crc’ is not a recognized feature for this target (ignoring feature)
‘+crypto’ is not a recognized feature for this target (ignoring feature)
‘+fp-armv8’ is not a recognized feature for this target (ignoring feature)
‘+lse’ is not a recognized feature for this target (ignoring feature)
‘+neon’ is not a recognized feature for this target (ignoring feature)
‘+crc’ is not a recognized feature for this target (ignoring feature)
‘+crypto’ is not a recognized feature for this target (ignoring feature)
‘+fp-armv8’ is not a recognized feature for this target (ignoring feature)
‘+lse’ is not a recognized feature for this target (ignoring feature)
‘+neon’ is not a recognized feature for this target (ignoring feature)
‘+crc’ is not a recognized feature for this target (ignoring feature)
‘+crypto’ is not a recognized feature for this target (ignoring feature)
Segmentation fault

I have a similar problem but with the opposite configuration. I am trying to execute example from EXLA documentation:

fun = fn a, b -> Nx.add(a, b) end
left = Nx.tensor(1, type: {:u, 8})
right = Nx.tensor([1, 2, 3], type: {:u, 16})
EXLA.jit(fun).(left, right)

which works on MacBook Air M2 but when I try to run it in the application built in the Docker for Ubuntu 22.04 (ARM) it crashes with the same error message given in UPDATE part altogether with the segmentation fault at the end.

I wanted to debug it with gdb but could not find core dump file anywhere.

The issue was fixed in the new version of exla, here is the PR with the solution: Add Docker build script for Linux ARM by jonatanklosko · Pull Request #60 · elixir-nx/xla · GitHub

Hello Guys, thanks for the topic, I’m experiencing the same issue when running my docker container.

* (Mix) Could not start application exla: EXLA.Application.start(:normal, []) returned an error: shutdown: failed to start child: EXLA.Logger
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function EXLA.NIF.start_log_sink/1 is undefined (module EXLA.NIF is not available)
            (exla 0.7.3) EXLA.NIF.start_log_sink(#PID<0.230.0>)
            (exla 0.7.3) lib/exla/logger.ex:12: EXLA.Logger.init/1
            (stdlib 6.1.2) gen_server.erl:2229: :gen_server.init_it/2
            (stdlib 6.1.2) gen_server.erl:2184: :gen_server.init_it/6
            (stdlib 6.1.2) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

This is my dockerfile: (Just FYI it’s simple Phoenix API only. No DB No views, it uses Bumblebee WIth Exla and NX)

FROM elixir:latest

RUN apt-get update && apt-get install -y \
    build-essential \
    gcc \
    g++ \
    make \
    && rm -rf /var/lib/apt/lists/*

RUN mix local.hex --force && mix local.rebar --force

ENV MIX_ENV=dev \
    PHOENIX_VERSION=1.7.11
RUN mix archive.install hex phx_new $PHOENIX_VERSION --force
WORKDIR /app
COPY mix.exs mix.lock ./
RUN mix do deps.get, deps.compile
COPY . .
RUN mix compile
RUN mix phx.digest

EXPOSE 80

ENTRYPOINT ["mix", "do", "phx.server"]

mix.exs deps:

defp deps do
    [
      {:phoenix, "~> 1.7.11"},
      {:finch, "~> 0.13"},
      {:telemetry_metrics, "~> 0.6"},
      {:telemetry_poller, "~> 1.0"},
      {:gettext, "~> 0.20"},
      {:jason, "~> 1.2"},
      {:dns_cluster, "~> 0.1.1"},
      {:bandit, "~> 1.2"},
      # custom:
      {:req, "~> 0.5.2"},
      {:dotenv, "~> 3.1"},
      {:bumblebee, "~> 0.5"},
      {:exla, "~> 0.5"},
      {:briefly, "~> 0.5.1"},
      {:corsica, "~> 2.1"}
    ]
  end

config.exs:

import Config

config :exla, :clients,
  cuda: [platform: :cuda],
  rocm: [platform: :rocm],
  tpu: [platform: :tpu],
  host: [platform: :host]

config :nx, :default_backend, EXLA.Backend

I would highly appreciate any help