I’m trying to build a phoenix app which use bumblebee, and I can’t successfully build a image since I want to cache the ai model from huggingface. just like Speed up your boot times with this one Dockerfile trick · The Phoenix Files do.
Error message:
=> ERROR [builder 15/18] RUN mix run -e 'MyApp.Application.load_serving()' --no-start 8.0s
------
> [builder 15/18] RUN mix run -e 'MyApp.Application.load_serving()' --no-start:
|==============
#0 5.675 [output clipped, log limit 100KiB/s reached]
|========================================== | 78% (117.37/151.0
#0 6.084 [output clipped, log limit 100KiB/s reached]
#0 7.910 ** (exit) exited in: GenServer.call(EXLA.Client, {:client, :host, [platform: :host]}, :infinity)
#0 7.910 ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
#0 7.910 (elixir 1.15.6) lib/gen_server.ex:1063: GenServer.call/3
#0 7.910 (exla 0.6.1) lib/exla/backend.ex:154: EXLA.Backend.client_and_device_id/1
#0 7.910 (exla 0.6.1) lib/exla/backend.ex:44: EXLA.Backend.from_binary/3
#0 7.910 (bumblebee 0.4.2) lib/bumblebee/conversion/pytorch/loader.ex:79: Bumblebee.Conversion.PyTorch.Loader.object_resolver/1
#0 7.910 (unpickler 0.1.0) lib/unpickler.ex:828: Unpickler.resolve_object/2
#0 7.910 (unpickler 0.1.0) lib/unpickler.ex:818: anonymous fn/2 in Unpickler.finalize_stack_items/2
#0 7.910 (elixir 1.15.6) lib/map.ex:957: Map.get_and_update/3
#0 7.910 nofile:1: (file)
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c mix run -e 'MyApp.Application.load_serving()' --no-start]: exit code: 1
Here is my Dockerfile:
ARG ELIXIR_VERSION=1.15.6
ARG OTP_VERSION=26.1.1
ARG DEBIAN_VERSION=bullseye-20230612-slim
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} as builder
# install build dependencies
RUN apt-get update -y && apt-get install -y build-essential git curl \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
# prepare build dir
WORKDIR /app
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV
ENV MIX_ENV="prod"
ENV BUMBLEBEE_CACHE_DIR=/app/.bumblebee
# install mix dependencies
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config
# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile
COPY priv priv
COPY lib lib
COPY assets assets
# compile assets
RUN mix assets.deploy
# Compile the release
RUN mix compile
# NEW HERE
# Download the HuggingFace models to cache them
RUN mix run -e 'MyApp.Application.load_serving()' --no-start
# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/
COPY rel rel
RUN mix release
# start a new build stage so that the final image will only contain
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}
RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales curl ffmpeg wget \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
# Set the locale
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR "/app"
RUN chown nobody /app
# set runner ENV
ENV MIX_ENV="prod"
# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/myapp ./
COPY --from=builder --chown=nobody:root /app/.bumblebee/ ./.bumblebee
USER nobody
# NEW HERE
ENV BUMBLEBEE_CACHE_DIR=/app/.bumblebee
ENV BUMBLEBEE_OFFLINE=true
CMD ["/app/bin/server"]
Does anybody have a clue on how to fix this?