Subodh358 commited on
Commit
0615244
·
verified ·
1 Parent(s): a8a3d39

Upload 3 files

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -0
  2. app.py +4 -0
Dockerfile CHANGED
@@ -10,6 +10,12 @@ COPY . /app
10
  # Install any needed packages specified in requirements.txt
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
 
 
 
 
 
 
13
  # Make port 80 available to the world outside this container
14
  EXPOSE 80
15
 
 
10
  # Install any needed packages specified in requirements.txt
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Create a writable cache directory
14
+ RUN mkdir -p /app/cache
15
+
16
+ # Set environment variable for the Transformers cache directory
17
+ ENV TRANSFORMERS_CACHE=/app/cache
18
+
19
  # Make port 80 available to the world outside this container
20
  EXPOSE 80
21
 
app.py CHANGED
@@ -1,9 +1,13 @@
1
  from fastapi import FastAPI
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
 
4
 
5
  app = FastAPI()
6
 
 
 
 
7
  # Load the model and tokenizer
8
  model_name = "unsloth/llama-3-8b-bnb-4bit"
9
  tokenizer = AutoTokenizer.from_pretrained(model_name)
 
1
  from fastapi import FastAPI
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
4
+ import os
5
 
6
  app = FastAPI()
7
 
8
+ # Set the cache directory environment variable
9
+ os.environ["TRANSFORMERS_CACHE"] = "/app/cache"
10
+
11
  # Load the model and tokenizer
12
  model_name = "unsloth/llama-3-8b-bnb-4bit"
13
  tokenizer = AutoTokenizer.from_pretrained(model_name)