Spaces:
Running
Running
Commit
Β·
6df633f
1
Parent(s):
d30125c
new docker fix
Browse files- Dockerfile +14 -6
Dockerfile
CHANGED
@@ -15,19 +15,27 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
15 |
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
16 |
|
17 |
# β
Set environment variables to a writable path
|
18 |
-
ENV TRANSFORMERS_CACHE=/app/cache
|
19 |
ENV HF_HOME=/app/cache
|
|
|
20 |
ENV TOKENIZERS_PARALLELISM=false
|
21 |
ENV OMP_NUM_THREADS=1
|
22 |
|
23 |
-
# β
Create
|
24 |
-
RUN mkdir -p /app/cache
|
25 |
|
26 |
# Copy application
|
27 |
COPY . .
|
28 |
|
29 |
-
# β
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
EXPOSE 7860
|
31 |
|
32 |
-
# β
Run app
|
33 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
|
|
|
15 |
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
|
16 |
|
17 |
# β
Set environment variables to a writable path
|
|
|
18 |
ENV HF_HOME=/app/cache
|
19 |
+
ENV TRANSFORMERS_CACHE=/app/cache
|
20 |
ENV TOKENIZERS_PARALLELISM=false
|
21 |
ENV OMP_NUM_THREADS=1
|
22 |
|
23 |
+
# β
Create cache directory with proper permissions
|
24 |
+
RUN mkdir -p /app/cache && chmod -R 777 /app/cache
|
25 |
|
26 |
# Copy application
|
27 |
COPY . .
|
28 |
|
29 |
+
# β
Pre-download the model during build (optional but recommended)
|
30 |
+
RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
|
31 |
+
AutoTokenizer.from_pretrained('distilgpt2', cache_dir='/app/cache'); \
|
32 |
+
AutoModelForCausalLM.from_pretrained('distilgpt2', cache_dir='/app/cache')" || echo "Model download failed, will retry at runtime"
|
33 |
+
|
34 |
+
# β
Ensure cache directory is writable after model download
|
35 |
+
RUN chmod -R 777 /app/cache
|
36 |
+
|
37 |
+
# β
Expose correct port
|
38 |
EXPOSE 7860
|
39 |
|
40 |
+
# β
Run app
|
41 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
|