Skip to content

Commit

Permalink
feat: Add llama (#23)
Browse files Browse the repository at this point in the history
* feat: Add llama

Signed-off-by: Ce Gao <[email protected]>

* chore: Add git for git clone in requirements

Signed-off-by: Ce Gao <[email protected]>

* fix: Disable PR trigger

Signed-off-by: Ce Gao <[email protected]>

---------

Signed-off-by: Ce Gao <[email protected]>
  • Loading branch information
gaocegege authored May 24, 2023
1 parent 126af31 commit 18f2a54
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 14 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ on:
types: [created]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/docker-publish.yml'

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

env:
REGISTRY: docker.io
IMAGE_NAME: modelzai/llm


jobs:
build:

strategy:
matrix:
image:
- name: modelzai/llm-chatglm-6b
dockerfile: ./images/base/Dockerfile
- name: modelzai/llm-llama-7b
dockerfile: ./images/llama/Dockerfile
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -50,7 +51,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ matrix.image.name }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
Expand All @@ -59,6 +60,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: ${{ matrix.image.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/gcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ on:
types: [created]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/gcr.yml'

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

env:
REGISTRY: us-central1-docker.pkg.dev/nth-guide-378813
IMAGE_NAME: modelzai/llm


jobs:
build:

strategy:
matrix:
image:
- name: modelzai/llm-chatglm-6b
dockerfile: ./images/base/Dockerfile
- name: modelzai/llm-llama-7b
dockerfile: ./images/llama/Dockerfile
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -54,7 +55,7 @@ jobs:
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ matrix.image.name }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
Expand All @@ -63,6 +64,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: ${{ matrix.image.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
File renamed without changes.
76 changes: 76 additions & 0 deletions images/llama-7b/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
ARG base=nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04

FROM ${base}

ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
ENV PATH /opt/conda/bin:$PATH

ENV MODELZ_MODEL=decapoda-research/llama-7b-hf
ENV MODELZ_TOKENIZER=decapoda-research/llama-7b-hf

ARG MOSEC_PORT=8080
ENV MOSEC_PORT=${MOSEC_PORT}

ARG CONDA_VERSION=py310_22.11.1-1

RUN apt update && \
apt install -y --no-install-recommends \
wget \
git \
build-essential \
ca-certificates && \
rm -rf /var/lib/apt/lists/*

RUN set -x && \
UNAME_M="$(uname -m)" && \
if [ "${UNAME_M}" = "x86_64" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh"; \
SHA256SUM="00938c3534750a0e4069499baf8f4e6dc1c2e471c86a59caa0dd03f4a9269db6"; \
elif [ "${UNAME_M}" = "s390x" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-s390x.sh"; \
SHA256SUM="a150511e7fd19d07b770f278fb5dd2df4bc24a8f55f06d6274774f209a36c766"; \
elif [ "${UNAME_M}" = "aarch64" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-aarch64.sh"; \
SHA256SUM="48a96df9ff56f7421b6dd7f9f71d548023847ba918c3826059918c08326c2017"; \
elif [ "${UNAME_M}" = "ppc64le" ]; then \
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-ppc64le.sh"; \
SHA256SUM="4c86c3383bb27b44f7059336c3a46c34922df42824577b93eadecefbf7423836"; \
fi && \
wget "${MINICONDA_URL}" -O miniconda.sh -q && \
echo "${SHA256SUM} miniconda.sh" > shasum && \
if [ "${CONDA_VERSION}" != "latest" ]; then sha256sum --check --status shasum; fi && \
mkdir -p /opt && \
bash miniconda.sh -b -p /opt/conda && \
rm miniconda.sh shasum && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
/opt/conda/bin/conda clean -afy

RUN conda create -n envd python=3.9

ENV ENVD_PREFIX=/opt/conda/envs/envd/bin

RUN update-alternatives --install /usr/bin/python python ${ENVD_PREFIX}/python 1 && \
update-alternatives --install /usr/bin/python3 python3 ${ENVD_PREFIX}/python3 1 && \
update-alternatives --install /usr/bin/pip pip ${ENVD_PREFIX}/pip 1 && \
update-alternatives --install /usr/bin/pip3 pip3 ${ENVD_PREFIX}/pip3 1

COPY ./images/llama/requirements.txt /

RUN pip install -r requirements.txt

RUN mkdir -p /workspace

COPY main.py workspace/

WORKDIR /workspace

RUN python main.py --dry-run

# disable huggingface update check (could be very slow)
ENV HF_HUB_OFFLINE=true

ENTRYPOINT [ "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080", "--workers", "1" ]
12 changes: 12 additions & 0 deletions images/llama-7b/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
msgpack
mosec
torch --extra-index-url https://download.pytorch.org/whl/cu116
diffusers[torch]
# Ref https://github.com/huggingface/transformers/issues/22222
transformers @ git+https://github.com/zphang/transformers.git@68d640f7c368bcaaaecfc678f11908ebbd3d6176
sentencepiece
cpm_kernels
accelerate
llmspec
falcon
uvicorn

0 comments on commit 18f2a54

Please sign in to comment.