Spaces:
Runtime error
Runtime error
gmerrill
commited on
Commit
·
18340a0
1
Parent(s):
877da1f
update
Browse files- Dockerfile +5 -1
- main.py +5 -3
Dockerfile
CHANGED
@@ -12,7 +12,11 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
12 |
|
13 |
RUN mkdir -p /.cache/huggingface/hub && \
|
14 |
chmod a+rw /.cache/huggingface/hub && \
|
15 |
-
echo made cache dir read-write
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Set up a new user named "user" with user ID 1000
|
18 |
RUN useradd -m -u 1000 user
|
|
|
12 |
|
13 |
RUN mkdir -p /.cache/huggingface/hub && \
|
14 |
chmod a+rw /.cache/huggingface/hub && \
|
15 |
+
echo made huggingface cache dir read-write
|
16 |
+
|
17 |
+
RUN mkdir -p /.cache/gorilla && \
|
18 |
+
chmod a+rw /.cache/gorilla && \
|
19 |
+
echo made gorilla cache dir read-write
|
20 |
|
21 |
# Set up a new user named "user" with user ID 1000
|
22 |
RUN useradd -m -u 1000 user
|
main.py
CHANGED
@@ -29,7 +29,7 @@ def get_prompt(user_query: str, functions: list = []) -> str:
|
|
29 |
device : str = "cuda:0" if torch.cuda.is_available() else "cpu"
|
30 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
31 |
|
32 |
-
result = subprocess.run('ls -lH', shell=True, capture_output=True, text=True)
|
33 |
log(result.stdout)
|
34 |
|
35 |
model_id : str = "gorilla-llm/gorilla-openfunctions-v1"
|
@@ -37,11 +37,13 @@ log('AutoTokenizer.from_pretrained ...')
|
|
37 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
38 |
log('AutoModelForCausalLM.from_pretrained ...')
|
39 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True)
|
|
|
|
|
40 |
|
41 |
-
result = subprocess.run('ls -lH', shell=True, capture_output=True, text=True)
|
42 |
log(result.stdout)
|
43 |
|
44 |
-
log('
|
45 |
model.to(device)
|
46 |
|
47 |
log('FastAPI setup ...')
|
|
|
29 |
device : str = "cuda:0" if torch.cuda.is_available() else "cpu"
|
30 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
31 |
|
32 |
+
result = subprocess.run('pwd && ls -lH && find /.cache/huggingface/hub && find /.cache/gorilla', shell=True, capture_output=True, text=True)
|
33 |
log(result.stdout)
|
34 |
|
35 |
model_id : str = "gorilla-llm/gorilla-openfunctions-v1"
|
|
|
37 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
38 |
log('AutoModelForCausalLM.from_pretrained ...')
|
39 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True)
|
40 |
+
log('AutoModelForCausalLM.save_pretrained ...')
|
41 |
+
model.save_pretrained('/.cache/gorilla')
|
42 |
|
43 |
+
result = subprocess.run('pwd && ls -lH && find /.cache/huggingface/hub && find /.cache/gorilla', shell=True, capture_output=True, text=True)
|
44 |
log(result.stdout)
|
45 |
|
46 |
+
log('model.to(device) ...')
|
47 |
model.to(device)
|
48 |
|
49 |
log('FastAPI setup ...')
|