abedelbahnasy55 commited on
Commit
5b8300e
·
1 Parent(s): c27b1a4

Switch to llama-cpp-python and fix build

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -4
Dockerfile CHANGED
@@ -1,13 +1,36 @@
1
  FROM python:3.10-slim
 
2
  WORKDIR /app
3
- RUN apt-get update && apt-get install -y build-essential cmake git curl libopenblas-dev && rm -rf /var/lib/apt/lists/*
4
- RUN git clone https://github.com/ggml-org/llama.cpp.git .
5
- RUN make LLAMA_OPENBLAS=1 llama-server
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  RUN curl -L -o gemma-4-e4b.gguf https://huggingface.co/unsloth/gemma-4-E4B-it-GGUF/resolve/main/gemma-4-E4B-it-UD-Q5_K_XL.gguf
7
  RUN curl -L -o mmproj.gguf https://huggingface.co/unsloth/gemma-4-E4B-it-GGUF/resolve/main/mmproj-BF16.gguf
 
 
8
  COPY requirements.txt .
9
  RUN pip install --no-cache-dir -r requirements.txt
 
 
10
  COPY app.py .
 
 
11
  EXPOSE 7860
12
  EXPOSE 8080
13
- CMD ./llama-server -m gemma-4-e4b.gguf --mmproj mmproj.gguf --port 8080 --host 127.0.0.1 -c 8192 --cache-ram 2048 -ctxcp 2 --threads 2 & uvicorn app:app --host 0.0.0.0 --port 7860
 
 
 
 
1
  FROM python:3.10-slim
2
+
3
  WORKDIR /app
4
+
5
+ # تثبيت الحزم الأساسية وأدوات البناء
6
+ RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ cmake \
9
+ git \
10
+ curl \
11
+ libopenblas-dev \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # تثبيت مكتبة llama-cpp-python مع دعم OpenBLAS
15
+ # (استخدام عجلة جاهزة لتسريع البناء)
16
+ RUN pip install --no-cache-dir \
17
+ https://huggingface.co/Luigi/llama-cpp-python-wheels-hf-spaces-free-cpu/resolve/main/llama_cpp_python-0.3.22-cp310-cp310-linux_x86_64.whl
18
+
19
+ # تنزيل ملفات النموذج
20
  RUN curl -L -o gemma-4-e4b.gguf https://huggingface.co/unsloth/gemma-4-E4B-it-GGUF/resolve/main/gemma-4-E4B-it-UD-Q5_K_XL.gguf
21
  RUN curl -L -o mmproj.gguf https://huggingface.co/unsloth/gemma-4-E4B-it-GGUF/resolve/main/mmproj-BF16.gguf
22
+
23
+ # نسخ متطلبات بايثون وتثبيتها
24
  COPY requirements.txt .
25
  RUN pip install --no-cache-dir -r requirements.txt
26
+
27
+ # نسخ تطبيق FastAPI
28
  COPY app.py .
29
+
30
+ # فتح المنافذ المطلوبة
31
  EXPOSE 7860
32
  EXPOSE 8080
33
+
34
+ # تشغيل الخدمة: llama-server ثم uvicorn
35
+ CMD python -c "import llama_cpp.server; llama_cpp.server.main()" --model gemma-4-e4b.gguf --mmproj mmproj.gguf --port 8080 --host 127.0.0.1 --n_ctx 8192 --cache_ram 2048 --n_threads 2 & \
36
+ uvicorn app:app --host 0.0.0.0 --port 7860