Spaces:
Runtime error
Runtime error
Commit ·
a2ce8c8
1
Parent(s): c6c330f
Use Python script for reliable model download
Browse files- Dockerfile +15 -11
Dockerfile
CHANGED
|
@@ -2,7 +2,7 @@ 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 \
|
|
@@ -14,13 +14,13 @@ RUN apt-get update && apt-get install -y \
|
|
| 14 |
libvips-dev \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
-
#
|
| 18 |
RUN update-ca-certificates
|
| 19 |
|
| 20 |
-
#
|
| 21 |
RUN git clone https://github.com/ggml-org/llama.cpp.git .
|
| 22 |
|
| 23 |
-
#
|
| 24 |
RUN mkdir build && cd build && cmake .. \
|
| 25 |
-DLLAMA_OPENBLAS=ON \
|
| 26 |
-DLLAMA_OPENSSL=ON \
|
|
@@ -28,20 +28,24 @@ RUN mkdir build && cd build && cmake .. \
|
|
| 28 |
-DLLAMA_VIP=ON \
|
| 29 |
&& cmake --build . --config Release -j 2 --target llama-server
|
| 30 |
|
| 31 |
-
#
|
| 32 |
COPY requirements.txt .
|
| 33 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
RUN
|
| 37 |
-
|
|
|
|
| 38 |
|
| 39 |
-
#
|
|
|
|
|
|
|
|
|
|
| 40 |
COPY app.py .
|
| 41 |
|
| 42 |
-
#
|
| 43 |
EXPOSE 7860
|
| 44 |
EXPOSE 8080
|
| 45 |
|
| 46 |
-
#
|
| 47 |
CMD ./build/bin/llama-server -m gemma-4-E4B-it-UD-Q5_K_XL.gguf --mmproj mmproj-BF16.gguf --port 8080 --host 127.0.0.1 -c 4096 --cache-ram 1536 --threads 1 --threads-batch 1 --parallel 1 --flash-attn on & uvicorn app:app --host 0.0.0.0 --port 7860
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# تثبيت الحزم الأساسية + أدوات البناء + OpenSSL + شهادات CA + libvips
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
build-essential \
|
| 8 |
cmake \
|
|
|
|
| 14 |
libvips-dev \
|
| 15 |
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
|
| 17 |
+
# تحديث شهادات CA
|
| 18 |
RUN update-ca-certificates
|
| 19 |
|
| 20 |
+
# استنساخ llama.cpp الرسمي
|
| 21 |
RUN git clone https://github.com/ggml-org/llama.cpp.git .
|
| 22 |
|
| 23 |
+
# بناء llama-server مع دعم OpenBLAS و OpenSSL و CURL و libvips
|
| 24 |
RUN mkdir build && cd build && cmake .. \
|
| 25 |
-DLLAMA_OPENBLAS=ON \
|
| 26 |
-DLLAMA_OPENSSL=ON \
|
|
|
|
| 28 |
-DLLAMA_VIP=ON \
|
| 29 |
&& cmake --build . --config Release -j 2 --target llama-server
|
| 30 |
|
| 31 |
+
# نسخ متطلبات بايثون وتثبيتها (بما فيها huggingface_hub)
|
| 32 |
COPY requirements.txt .
|
| 33 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
|
| 35 |
+
# إنشاء سكريبت بايثون لتنزيل النموذج
|
| 36 |
+
RUN echo 'from huggingface_hub import hf_hub_download\n\
|
| 37 |
+
hf_hub_download(repo_id="unsloth/gemma-4-E4B-it-GGUF", filename="gemma-4-E4B-it-UD-Q5_K_XL.gguf", local_dir=".")\n\
|
| 38 |
+
hf_hub_download(repo_id="unsloth/gemma-4-E4B-it-GGUF", filename="mmproj-BF16.gguf", local_dir=".")' > download_model.py
|
| 39 |
|
| 40 |
+
# تنفيذ سكريبت التحميل
|
| 41 |
+
RUN python download_model.py
|
| 42 |
+
|
| 43 |
+
# نسخ تطبيق FastAPI
|
| 44 |
COPY app.py .
|
| 45 |
|
| 46 |
+
# فتح المنافذ
|
| 47 |
EXPOSE 7860
|
| 48 |
EXPOSE 8080
|
| 49 |
|
| 50 |
+
# تشغيل الخدمة مع إعدادات الأداء المضمونة
|
| 51 |
CMD ./build/bin/llama-server -m gemma-4-E4B-it-UD-Q5_K_XL.gguf --mmproj mmproj-BF16.gguf --port 8080 --host 127.0.0.1 -c 4096 --cache-ram 1536 --threads 1 --threads-batch 1 --parallel 1 --flash-attn on & uvicorn app:app --host 0.0.0.0 --port 7860
|