Hoang Kha commited on
Commit
b608f06
·
1 Parent(s): 2215891

fix cache permission using HF_HOME=/home/user/.cache/huggingface

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -3
  2. main.py +3 -5
Dockerfile CHANGED
@@ -9,8 +9,7 @@ RUN pip install --no-cache-dir -r requirements.txt
9
 
10
  EXPOSE 7860
11
 
12
- ENV HF_HOME=/app/hf_cache
13
- ENV TRANSFORMERS_CACHE=/app/hf_cache
14
- RUN mkdir -p /app/hf_cache
15
 
16
  CMD ["python", "main.py"]
 
9
 
10
  EXPOSE 7860
11
 
12
+ ENV HF_HOME=/home/user/.cache/huggingface
13
+ RUN mkdir -p /home/user/.cache/huggingface
 
14
 
15
  CMD ["python", "main.py"]
main.py CHANGED
@@ -4,11 +4,9 @@ from langdetect import detect
4
  import torch
5
  import torch.nn.functional as F
6
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
7
- CACHE_DIR = os.path.join(os.getcwd(), "hf_cache")
8
- os.makedirs(CACHE_DIR, exist_ok=True)
9
-
10
- os.environ["HF_HOME"] = CACHE_DIR
11
- os.environ["TRANSFORMERS_CACHE"] = CACHE_DIR
12
 
13
  app = Flask(__name__)
14
 
 
4
  import torch
5
  import torch.nn.functional as F
6
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
7
+ HF_CACHE_DIR = "/home/user/.cache/huggingface"
8
+ os.makedirs(HF_CACHE_DIR, exist_ok=True)
9
+ os.environ["HF_HOME"] = HF_CACHE_DIR
 
 
10
 
11
  app = Flask(__name__)
12