Spaces:
Sleeping
Sleeping
LVKinyanjui
commited on
Commit
·
4f37c86
1
Parent(s):
71c54ff
Set HF_HOME to writeable directory
Browse files- Dockerfile +7 -4
- modules/inference/instruct.py +6 -4
Dockerfile
CHANGED
@@ -2,10 +2,13 @@ FROM ubuntu:22.04
|
|
2 |
|
3 |
WORKDIR /app
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
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 |
-
|
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
|