Commit ·
232e94e
1
Parent(s): e3bb7c6
fix: enforce transformers offline mode and limit TF threads to prevent timeouts on HF Spaces
Browse files- Dockerfile +9 -0
Dockerfile
CHANGED
|
@@ -18,6 +18,15 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 18 |
# Pre-download HF model to avoid file-lock hangs at runtime on HF Spaces
|
| 19 |
RUN python -c "import os; os.environ['TF_CPP_MIN_LOG_LEVEL']='3'; from transformers import pipeline; pipeline('zero-shot-classification', model='typeform/distilbert-base-uncased-mnli', framework='tf')"
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
COPY --chown=user:user . /app
|
| 22 |
|
| 23 |
# HF Spaces run on port 7860
|
|
|
|
| 18 |
# Pre-download HF model to avoid file-lock hangs at runtime on HF Spaces
|
| 19 |
RUN python -c "import os; os.environ['TF_CPP_MIN_LOG_LEVEL']='3'; from transformers import pipeline; pipeline('zero-shot-classification', model='typeform/distilbert-base-uncased-mnli', framework='tf')"
|
| 20 |
|
| 21 |
+
# Limit TensorFlow threads to prevent CPU thrashing on Hugging Face Spaces
|
| 22 |
+
ENV OMP_NUM_THREADS=2
|
| 23 |
+
ENV TF_NUM_INTRAOP_THREADS=2
|
| 24 |
+
ENV TF_NUM_INTEROP_THREADS=2
|
| 25 |
+
|
| 26 |
+
# Set Hugging Face offline mode to prevent network timeouts during inference
|
| 27 |
+
ENV TRANSFORMERS_OFFLINE=1
|
| 28 |
+
ENV HF_HUB_OFFLINE=1
|
| 29 |
+
|
| 30 |
COPY --chown=user:user . /app
|
| 31 |
|
| 32 |
# HF Spaces run on port 7860
|