LVKinyanjui commited on
Commit
4f37c86
·
1 Parent(s): 71c54ff

Set HF_HOME to writeable directory

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -4
  2. modules/inference/instruct.py +6 -4
Dockerfile CHANGED
@@ -2,10 +2,13 @@ FROM ubuntu:22.04
2
 
3
  WORKDIR /app
4
 
5
- # ARG HOME= /app
6
- # # RUN mkdir ${HOME}
7
- # ENV SENTENCE_TRANSFORMERS_HOME=${HOME}
8
- # ENV TORCH_HOME=${HOME}
 
 
 
9
 
10
  RUN apt update \
11
  && apt install python3.10 pip -y \
 
2
 
3
  WORKDIR /app
4
 
5
+ ARG HF_HOME=/app/.cache
6
+ RUN mkdir ${HF_HOME} \
7
+ && chmod 775 ${HF_HOME}
8
+
9
+ ENV HF_HOME=${HF_HOME}
10
+ # DO NOT USE: Depreccated
11
+ # ENV TRANSFORMERS_CACHE="/app/.cache"
12
 
13
  RUN apt update \
14
  && apt install python3.10 pip -y \
modules/inference/instruct.py CHANGED
@@ -4,14 +4,16 @@ import json, os
4
  # if not os.path.exists(cache_dir):
5
  # os.mkdir(cache_dir)
6
 
 
 
 
 
7
  cache_dir = "."
8
 
9
  os.environ["TORCH_HOME"] = cache_dir
10
  os.environ["TRANSFORMERS_HOME"] = cache_dir
11
-
12
- import transformers, torch
13
-
14
- from huggingface_hub import login
15
 
16
  # CONSTANTS
17
  MAX_NEW_TOKENS = 1024
 
4
  # if not os.path.exists(cache_dir):
5
  # os.mkdir(cache_dir)
6
 
7
+ import transformers, torch
8
+
9
+ from huggingface_hub import login
10
+
11
  cache_dir = "."
12
 
13
  os.environ["TORCH_HOME"] = cache_dir
14
  os.environ["TRANSFORMERS_HOME"] = cache_dir
15
+ os.environ["HF_HOME"] = cache_dir
16
+ os.environ["TRANSFORMERS_CACHE"] = cache_dir
 
 
17
 
18
  # CONSTANTS
19
  MAX_NEW_TOKENS = 1024