Spaces:
Sleeping
Sleeping
Ubuntu
commited on
Commit
·
429de13
1
Parent(s):
33b2933
Fix: set cache dir for Transformers to work on Spaces
Browse files- Dockerfile +10 -4
Dockerfile
CHANGED
|
@@ -1,8 +1,14 @@
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
# Install system dependencies
|
| 4 |
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
# Set working directory
|
| 7 |
WORKDIR /app
|
| 8 |
|
|
@@ -12,12 +18,12 @@ COPY . .
|
|
| 12 |
# Install Python packages
|
| 13 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
|
| 15 |
-
# Download Hugging Face model
|
| 16 |
RUN python -c "from transformers import AutoTokenizer, AutoModel; \
|
| 17 |
-
AutoTokenizer.from_pretrained('aNameNobodyChose/quote-caster-encoder'); \
|
| 18 |
-
AutoModel.from_pretrained('aNameNobodyChose/quote-caster-encoder')"
|
| 19 |
|
| 20 |
-
# Gradio default port
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
# Run the Gradio app
|
|
|
|
| 1 |
FROM python:3.10-slim
|
| 2 |
|
| 3 |
+
# Set environment variables
|
| 4 |
+
ENV TRANSFORMERS_CACHE=/data/transformers
|
| 5 |
+
|
| 6 |
# Install system dependencies
|
| 7 |
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
+
# Create writable cache directory
|
| 10 |
+
RUN mkdir -p /data/transformers
|
| 11 |
+
|
| 12 |
# Set working directory
|
| 13 |
WORKDIR /app
|
| 14 |
|
|
|
|
| 18 |
# Install Python packages
|
| 19 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
|
| 21 |
+
# Download Hugging Face model at build time (optional but recommended for faster app startup)
|
| 22 |
RUN python -c "from transformers import AutoTokenizer, AutoModel; \
|
| 23 |
+
AutoTokenizer.from_pretrained('aNameNobodyChose/quote-caster-encoder', cache_dir='/data/transformers'); \
|
| 24 |
+
AutoModel.from_pretrained('aNameNobodyChose/quote-caster-encoder', cache_dir='/data/transformers')"
|
| 25 |
|
| 26 |
+
# Expose Gradio's default port
|
| 27 |
EXPOSE 7860
|
| 28 |
|
| 29 |
# Run the Gradio app
|