LVKinyanjui commited on
Commit
184d783
1 Parent(s): a04c69c

Attempting another fix for transformers permission error

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -0
  2. app_inference.py +5 -2
Dockerfile CHANGED
@@ -6,6 +6,9 @@ WORKDIR /app
6
  COPY requirements.txt .
7
  RUN python -m pip install --no-cache-dir -r requirements.txt
8
 
 
 
 
9
  # # Install ollama
10
  # RUN curl -fsSL https://ollama.com/install.sh | sh
11
 
 
6
  COPY requirements.txt .
7
  RUN python -m pip install --no-cache-dir -r requirements.txt
8
 
9
+ # To avert Permision error with transformer and hf models
10
+ RUN mkdir ./.cache
11
+
12
  # # Install ollama
13
  # RUN curl -fsSL https://ollama.com/install.sh | sh
14
 
app_inference.py CHANGED
@@ -9,6 +9,10 @@ from huggingface_hub import login
9
  MAX_NEW_TOKENS = 256
10
  SYSTEM_MESSAGE = "You are a hepful, knowledgeable assistant"
11
 
 
 
 
 
12
 
13
  # STREAMLIT UI AREA
14
 
@@ -18,8 +22,7 @@ submit = st.button("Submit")
18
 
19
  # MODEL AREA
20
  # Use the token to authenticate
21
- token = os.getenv("HF_TOKEN_READ")
22
- api = login(token=token)
23
  model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
24
 
25
  @st.cache_resource
 
9
  MAX_NEW_TOKENS = 256
10
  SYSTEM_MESSAGE = "You are a hepful, knowledgeable assistant"
11
 
12
+ # ENV VARS
13
+ # To avert Permision error with transformer and hf models
14
+ os.environ['SENTENCE_TRANSFORMERS_HOME'] = './.cache'
15
+ token = os.getenv("HF_TOKEN_READ")
16
 
17
  # STREAMLIT UI AREA
18
 
 
22
 
23
  # MODEL AREA
24
  # Use the token to authenticate
25
+ login(token=token)
 
26
  model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
27
 
28
  @st.cache_resource