Spaces:
Build error
Build error
Pratham Bhat
commited on
Commit
·
0252e20
1
Parent(s):
037b09f
Pull the model before starting the container
Browse files- Dockerfile +3 -0
- main.py +2 -2
Dockerfile
CHANGED
@@ -3,6 +3,7 @@ FROM python:3.9
|
|
3 |
WORKDIR /code
|
4 |
RUN mkdir -p /code && chmod -R 777 /code
|
5 |
RUN mkdir -p /.cache && chmod -R 777 /.cache
|
|
|
6 |
|
7 |
COPY ./requirements.txt /code/requirements.txt
|
8 |
|
@@ -10,4 +11,6 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
10 |
|
11 |
COPY . .
|
12 |
|
|
|
|
|
13 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
3 |
WORKDIR /code
|
4 |
RUN mkdir -p /code && chmod -R 777 /code
|
5 |
RUN mkdir -p /.cache && chmod -R 777 /.cache
|
6 |
+
RUN mkdir -p /.cache/huggingface && chmod -R 777 /.cache/huggingface
|
7 |
|
8 |
COPY ./requirements.txt /code/requirements.txt
|
9 |
|
|
|
11 |
|
12 |
COPY . .
|
13 |
|
14 |
+
RUN python3 -c "from transformers import AutoModelForCausalLM; AutoModelForCausalLM.from_pretrained('ibm-granite/granite-34b-code-instruct-8k', cache_dir='/.cache/huggingface')"
|
15 |
+
|
16 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
CHANGED
@@ -65,11 +65,11 @@ def setup():
|
|
65 |
|
66 |
model_path = "ibm-granite/granite-34b-code-instruct-8k"
|
67 |
print("Loading tokenizer for model: " + model_path, file=sys.stderr)
|
68 |
-
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
69 |
|
70 |
print("Loading Model for causal LM for model: " + model_path, file=sys.stderr)
|
71 |
# drop device_map if running on CPU
|
72 |
-
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
|
73 |
model.eval()
|
74 |
|
75 |
return model, tokenizer, device
|
|
|
65 |
|
66 |
model_path = "ibm-granite/granite-34b-code-instruct-8k"
|
67 |
print("Loading tokenizer for model: " + model_path, file=sys.stderr)
|
68 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, cache_dir="/.cache/huggingface")
|
69 |
|
70 |
print("Loading Model for causal LM for model: " + model_path, file=sys.stderr)
|
71 |
# drop device_map if running on CPU
|
72 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device, cache_dir="/.cache/huggingface")
|
73 |
model.eval()
|
74 |
|
75 |
return model, tokenizer, device
|