sankalphs commited on
Commit
a55c7de
·
1 Parent(s): e5d102f

fix: install libgomp1 + libgfortran5 so the prebuilt llama-cpp wheel can load

Browse files

The Space was failing at runtime with:
RuntimeError: Failed to load shared library
'/usr/local/lib/python3.11/site-packages/llama_cpp/lib/llama.so'

The prebuilt llama-cpp-python CPU wheel ships libllama.so, which
dynamically links against:
- libgomp.so.1 (OpenMP runtime)
- libgfortran.so.5 (Fortran runtime)

Neither of these is present in the python:3.11-slim base image, so
dlopen() fails the moment we construct the Llama() object. The
previous error-surfacing work surfaced this exact failure to the
status line (no more generic 'model not loaded'), which made the
root cause obvious.

Fix: apt-get install libgomp1 libgfortran5 in the Dockerfile. Also
keep cmake + build-essential as a safety net so pip can fall back
to a source build if the prebuilt wheel is ever unavailable for the
exact Python version. --prefer-binary is kept so we still use the
fast prebuilt wheel by default.

Tests (host Python, not Docker): 12 unit + 42 E2E + 12 verify_llm_status
all pass. The Docker fix will take effect on the next Space rebuild.

Files changed (1) hide show
  1. Dockerfile +16 -3
Dockerfile CHANGED
@@ -2,13 +2,26 @@ FROM python:3.11-slim
2
 
3
  WORKDIR /app
4
 
5
- # Install git for hf_hub_download and curl for health checks
6
- RUN apt-get update && apt-get install -y \
 
 
 
 
 
 
 
 
 
7
  git \
8
  curl \
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- # Copy requirements and install Python deps (uses prebuilt llama-cpp-python wheel)
12
  COPY requirements.txt .
13
  RUN pip install --no-cache-dir --prefer-binary -r requirements.txt
14
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # System dependencies:
6
+ # - git, curl : hf_hub_download + health checks
7
+ # - libgomp1, libgfortran5 : OpenMP + Fortran runtimes required by
8
+ # the prebuilt llama-cpp-python wheel's
9
+ # libllama.so (NOT in the slim base image;
10
+ # without these you get
11
+ # "Failed to load shared library ... libgomp.so.1")
12
+ # - cmake, build-essential : safety net so pip can build llama-cpp-python
13
+ # from source if the prebuilt wheel is ever
14
+ # unavailable for this Python version
15
+ RUN apt-get update && apt-get install -y --no-install-recommends \
16
  git \
17
  curl \
18
+ libgomp1 \
19
+ libgfortran5 \
20
+ cmake \
21
+ build-essential \
22
  && rm -rf /var/lib/apt/lists/*
23
 
24
+ # Copy requirements and install Python deps (prefer prebuilt llama-cpp-python wheel)
25
  COPY requirements.txt .
26
  RUN pip install --no-cache-dir --prefer-binary -r requirements.txt
27