Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move model download from the Docker image build step to the run script #19

Merged
merged 8 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions api/13B.Dockerfile

This file was deleted.

26 changes: 0 additions & 26 deletions api/70B.Dockerfile

This file was deleted.

11 changes: 2 additions & 9 deletions api/Dockerfile
edgar971 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# Define the image argument and provide a default value
ARG IMAGE=ghcr.io/abetlen/llama-cpp-python:latest

# Define the model file name and download url
ARG MODEL_FILE=llama-2-7b-chat.bin
ARG MODEL_DOWNLOAD_URL=https://huggingface.co/TheBloke/Nous-Hermes-Llama-2-7B-GGML/resolve/main/nous-hermes-llama-2-7b.ggmlv3.q4_0.bin

FROM ${IMAGE}

ARG MODEL_FILE
ARG MODEL_DOWNLOAD_URL

# Download the model file
# Install curl and create a directory for the models
RUN apt-get update -y && \
apt-get install --yes curl && \
mkdir -p /models && \
curl -L -o /models/${MODEL_FILE} ${MODEL_DOWNLOAD_URL}
make build

WORKDIR /app

Expand Down
20 changes: 19 additions & 1 deletion api/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
#!/bin/bash

make build
if [ -z "$MODEL" ]
then
echo "Please set the MODEL_FILE environment variable"
exit 1
fi

if [ -z "$MODEL_DOWNLOAD_URL" ]
then
echo "Please set the MODEL_DOWNLOAD_URL environment variable"
exit 1
fi


if [ ! -f $MODEL ]; then
echo "Model file not found. Downloading..."
curl -L -o $MODEL $MODEL_DOWNLOAD_URL
edgar971 marked this conversation as resolved.
Show resolved Hide resolved
else
echo "$MODEL model found."
fi

edgar971 marked this conversation as resolved.
Show resolved Hide resolved
# Get the number of available threads on the system
n_threads=$(grep -c ^processor /proc/cpuinfo)
Expand Down
5 changes: 4 additions & 1 deletion docker-compose-13b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ services:
# image: 'ghcr.io/getumbrel/llama-gpt-api-llama-2-13b-chat:latest'
build:
context: ./api
dockerfile: 13B.Dockerfile
dockerfile: Dockerfile
restart: on-failure
volumes:
- './models:/models'
environment:
MODEL: '/models/llama-2-13b-chat.bin'
USE_MLOCK: 1
MODEL_DOWNLOAD_URL: 'https://huggingface.co/TheBloke/Nous-Hermes-Llama2-GGML/resolve/main/nous-hermes-llama2-13b.ggmlv3.q4_0.bin'
cap_add:
- IPC_LOCK

Expand Down
5 changes: 4 additions & 1 deletion docker-compose-70b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ services:
# image: 'ghcr.io/getumbrel/llama-gpt-api-llama-2-70b-chat:latest'
build:
context: ./api
dockerfile: 70B.Dockerfile
dockerfile: Dockerfile
restart: on-failure
volumes:
- './models:/models'
environment:
MODEL: '/models/llama-2-70b-chat.bin'
MODEL_DOWNLOAD_URL: 'https://huggingface.co/TheBloke/Llama-2-70B-Chat-GGML/resolve/main/llama-2-70b-chat.ggmlv3.q4_0.bin'
# Llama 2 70B's grouping factor is 8 compared to 7B and 13B's 1. Currently,
# it's not possible to change this using --n_gqa with llama-cpp-python in
# run.sh, so we expose it as an environment variable.
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ services:
context: ./api
edgar971 marked this conversation as resolved.
Show resolved Hide resolved
dockerfile: Dockerfile
restart: on-failure
volumes:
- './models:/models'
environment:
MODEL: '/models/llama-2-7b-chat.bin'
MODEL_DOWNLOAD_URL: 'https://huggingface.co/TheBloke/Nous-Hermes-Llama-2-7B-GGML/resolve/main/nous-hermes-llama-2-7b.ggmlv3.q4_0.bin'

llama-gpt-ui:
image: 'ghcr.io/getumbrel/llama-gpt-ui:latest'
Expand Down