Skip to content

Commit

Permalink
refactor lagoon setup:
Browse files Browse the repository at this point in the history
- create lagoon specific docker-compose
- de-amazeeioify
- add chatbot-ui
  • Loading branch information
Schnitzel committed Aug 17, 2023
1 parent 4753dfd commit 7f1b002
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENV
data
2 changes: 1 addition & 1 deletion .lagoon.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docker-compose-yaml: docker-compose.yml
docker-compose-yaml: docker-compose.lagoon.yml
environments:
main:
routes:
Expand Down
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM python:3-slim-bullseye
ENV MODEL=WizardLM-13B-V1.2

# Update and upgrade the existing packages
# Update and upgrade the existing packages
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
python3 \
python3-pip \
Expand All @@ -22,17 +22,13 @@ RUN rm -rf /var/lib/apt/lists/*
# Set a working directory for better clarity
WORKDIR /app

COPY ./amazee_server.sh /app/amazee_server.sh
COPY ./start-llama2.sh /app/start-llama2.sh
COPY ./hug_model.py /app/hug_model.py
COPY ./fix-permissions.sh /app/fix-permissions.sh
RUN chmod +x /app/fix-permissions.sh

RUN mkdir -p /data \
&& /app/fix-permissions.sh /data \
&& /app/fix-permissions.sh /app

# Make the server start script executable
RUN chmod +x /app/amazee_server.sh
&& /app/fix-permissions.sh /data

# Set environment variable for the host
ENV HOST=0.0.0.0
Expand All @@ -41,4 +37,4 @@ ENV HOST=0.0.0.0
EXPOSE 8000

# Run the server start script
CMD ["/bin/sh", "/app/amazee_server.sh"]
CMD ["/app/start-llama2.sh"]
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ lagoon going llama2

# local run on mac M1
```sh
docker build --platform linux/amd64 .
docker run -it --platform linux/amd64
```

```sh
docker run --rm -it --platform linux/amd64 -v '/Users/marco/Downloads:/data' -p '8000:8000' $(docker build --platform linux/amd64 -q .)
docker-compose up -d
```

# curl test openai api
Expand Down
22 changes: 22 additions & 0 deletions docker-compose.lagoon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '2'
services:
llama2-api:
build: gpu.Dockerfile
labels:
lagoon.type: basic-persistent
lagoon.persistent: /data
lagoon.service.port: 8000
lagoon.autogeneratedroute: true
lagoon.gpu: true
volumes:
- ./data:/data:delegated
ports:
- "8000:8000"
ui:
build:
context: .
dockerfile: ui.Dockerfile
labels:
lagoon.type: node
ports:
- "3000:3000"
17 changes: 9 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ services:
llama2-api:
build:
context: .
dockerfile: gpu.Dockerfile
labels:
lagoon.type: basic-persistent
lagoon.persistent: /data
lagoon.service.port: 8000
lagoon.autogeneratedroute: true
lagoon.gpu: true
dockerfile: Dockerfile
volumes:
- ./app:/app:delegated
- ./data:/data:delegated
ports:
- "8000:8000"
platform: linux/amd64
ui:
build:
context: .
dockerfile: ui.Dockerfile
ports:
- "3000:3000"
15 changes: 5 additions & 10 deletions gpu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ RUN apt-get update && apt-get upgrade -y \
python3 python3-pip gcc wget \
ocl-icd-opencl-dev opencl-headers clinfo \
libclblast-dev libopenblas-dev \
&& mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
&& mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd \
&& rm -rf /var/lib/apt/lists/*

ENV CUDA_DOCKER_ARCH=all
ENV LLAMA_CUBLAS=1
Expand All @@ -19,23 +20,17 @@ RUN CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 pip install llama-cpp-python
# Run the server
ENV MODEL=vicuna-13B-v1.5-16K-GGML

# Clean up apt cache
RUN rm -rf /var/lib/apt/lists/*

# Set a working directory for better clarity
WORKDIR /app

COPY ./amazee_server.sh /app/amazee_server.sh
COPY ./start-llama2.sh /app/start-llama2.sh
COPY ./hug_model.py /app/hug_model.py
COPY ./fix-permissions.sh /app/fix-permissions.sh
RUN chmod +x /app/fix-permissions.sh

RUN mkdir -p /data \
&& /app/fix-permissions.sh /data \
&& /app/fix-permissions.sh /app
&& /app/fix-permissions.sh /data

# Make the server start script executable
RUN chmod +x /app/amazee_server.sh

# Set environment variable for the host
ENV HOST=0.0.0.0
Expand All @@ -44,4 +39,4 @@ ENV HOST=0.0.0.0
EXPOSE 8000

# Run the server start script
CMD ["/bin/sh", "/app/amazee_server.sh"]
CMD ["/app/start-llama2.sh"]
2 changes: 1 addition & 1 deletion amazee_server.sh → start-llama2.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ulimit -l unlimited
echo "Model: ${MODEL}"

python3 hug_model.py -s ${MODEL} -f "q5_1"
python3 -B -m llama_cpp.server --model /app/model.bin --n_gpu_layers=43
python3 -B -m llama_cpp.server --model /data/model.bin --n_gpu_layers=43
4 changes: 4 additions & 0 deletions ui.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ghcr.io/mckaywrigley/chatbot-ui:main

ENV OPENAI_API_KEY=not-needed \
OPENAI_API_HOST=http://llama2-api:8000

0 comments on commit 7f1b002

Please sign in to comment.