Spaces:
Running
Running
Thewhey-Brian
commited on
Commit
·
c015721
1
Parent(s):
a7c715b
Fix uid 1000 error: create user and set cache env vars early
Browse files- Dockerfile +3 -0
- app.py +5 -1
Dockerfile
CHANGED
|
@@ -1,6 +1,9 @@
|
|
| 1 |
# Dockerfile for Hugging Face Spaces deployment
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
|
|
|
|
|
|
|
|
|
| 4 |
# Install system dependencies including Rust (needed for rustbpe)
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
|
|
|
| 1 |
# Dockerfile for Hugging Face Spaces deployment
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Create a user with uid 1000 (typical HF Spaces user)
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
|
| 7 |
# Install system dependencies including Rust (needed for rustbpe)
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
app.py
CHANGED
|
@@ -7,8 +7,12 @@ This file is automatically detected and run by HF Spaces.
|
|
| 7 |
import os
|
| 8 |
import sys
|
| 9 |
|
| 10 |
-
# Set environment variables for HF Spaces
|
| 11 |
os.environ.setdefault("NANOCHAT_BASE_DIR", "/data")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Download model from HF if not present
|
| 14 |
def download_model():
|
|
|
|
| 7 |
import os
|
| 8 |
import sys
|
| 9 |
|
| 10 |
+
# Set environment variables for HF Spaces BEFORE any other imports
|
| 11 |
os.environ.setdefault("NANOCHAT_BASE_DIR", "/data")
|
| 12 |
+
os.environ.setdefault("TORCHINDUCTOR_CACHE_DIR", "/data/.cache/torch")
|
| 13 |
+
os.environ.setdefault("HF_HOME", "/data/.cache/huggingface")
|
| 14 |
+
os.environ.setdefault("TORCH_HOME", "/data/.cache/torch")
|
| 15 |
+
os.environ.setdefault("XDG_CACHE_HOME", "/data/.cache")
|
| 16 |
|
| 17 |
# Download model from HF if not present
|
| 18 |
def download_model():
|