ateetvatan commited on
Commit
a0d9a38
·
1 Parent(s): e2e640c

hf cache dir fixs

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -5
  2. model_loader.py +2 -2
Dockerfile CHANGED
@@ -2,8 +2,8 @@
2
  FROM python:3.10-slim
3
 
4
  # Set cache envs for Transformers & HF Hub (must come before any Python install)
5
- ENV TRANSFORMERS_CACHE=/app/cache
6
- ENV HF_HOME=/app/hf_home
7
 
8
  # Install system dependencies
9
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
@@ -11,9 +11,6 @@ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
11
  # Create app directory
12
  WORKDIR /app
13
 
14
- # Create cache directories (safe fallback in Docker)
15
- RUN mkdir -p /app/cache /app/hf_home
16
-
17
  # Copy requirements and install
18
  COPY requirements.txt .
19
  RUN pip install --upgrade pip && pip install -r requirements.txt
 
2
  FROM python:3.10-slim
3
 
4
  # Set cache envs for Transformers & HF Hub (must come before any Python install)
5
+ ENV HF_HOME=/data/hf_home
6
+ ENV TRANSFORMERS_CACHE=/data/cache
7
 
8
  # Install system dependencies
9
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
 
11
  # Create app directory
12
  WORKDIR /app
13
 
 
 
 
14
  # Copy requirements and install
15
  COPY requirements.txt .
16
  RUN pip install --upgrade pip && pip install -r requirements.txt
model_loader.py CHANGED
@@ -2,8 +2,8 @@
2
  import os
3
 
4
  # Safe fallback if ENV vars are not set (e.g., during local dev)
5
- os.environ.setdefault("TRANSFORMERS_CACHE", "/app/cache")
6
- os.environ.setdefault("HF_HOME", "/app/hf_home")
7
 
8
  from transformers import AutoTokenizer, AutoModelForCausalLM
9
  import torch, os
 
2
  import os
3
 
4
  # Safe fallback if ENV vars are not set (e.g., during local dev)
5
+ os.environ.setdefault("HF_HOME", "/data/hf_home")
6
+ os.environ.setdefault("TRANSFORMERS_CACHE", "/data/cache")
7
 
8
  from transformers import AutoTokenizer, AutoModelForCausalLM
9
  import torch, os