Browse Source

add experimental and wip worker containers

master
Hendrik Langer 2 years ago
parent
commit
32021270ba
  1. 5
      runpod/runpod-worker-sd/README.md
  2. 60
      runpod/runpod-worker-transformers/Dockerfile
  3. 11
      runpod/runpod-worker-transformers/README.md
  4. 17
      runpod/runpod-worker-transformers/model_fetcher.py
  5. 23
      runpod/runpod-worker-transformers/runpod_infer.py

5
runpod/runpod-worker-sd/README.md

@ -1,11 +1,16 @@
# NOT (YET) WORKING # NOT (YET) WORKING
uses (containers/)serverless-automatic instead
## old info serverless-ckpt-template
```
git clone https://github.com/runpod/serverless-ckpt-template.git git clone https://github.com/runpod/serverless-ckpt-template.git
cd serverless-ckpt-template cd serverless-ckpt-template
docker build --build-arg MODEL_URL=https://huggingface.co/hassanblend/HassanBlend1.5.1.2 -t magn418/runpod-hassan:1.5 . docker build --build-arg MODEL_URL=https://huggingface.co/hassanblend/HassanBlend1.5.1.2 -t magn418/runpod-hassan:1.5 .
docker login docker login
docker push magn418/runpod-hassan:1.5 docker push magn418/runpod-hassan:1.5
```
Models: Models:
PFG https://civitai.com/models/1227/pfg PFG https://civitai.com/models/1227/pfg

60
runpod/runpod-worker-transformers/Dockerfile

@ -1,46 +1,54 @@
ARG BASE_IMAGE=nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04 ARG BASE_IMAGE=nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
FROM ${BASE_IMAGE} as dev-base FROM ${BASE_IMAGE} as dev-base
ARG MODEL_NAME WORKDIR /
ENV MODEL_NAME=${MODEL_NAME}
WORKDIR /src
SHELL ["/bin/bash", "-o", "pipefail", "-c"] SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND noninteractive\ ENV DEBIAN_FRONTEND noninteractive\
SHELL=/bin/bash SHELL=/bin/bash
RUN apt-key del 7fa2af80
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
RUN apt-get update --yes && \ RUN apt-get update --yes && \
# - apt-get upgrade is run to patch known vulnerabilities in apt-get packages as
# the ubuntu base image is rebuilt too seldom sometimes (less than once a month)
apt-get upgrade --yes && \ apt-get upgrade --yes && \
apt install --yes --no-install-recommends \ apt install --yes --no-install-recommends \
build-essential \
ca-certificates \
git \
git-lfs \
wget \ wget \
curl \
bash \ bash \
libgl1 \
software-properties-common \
openssh-server && \ openssh-server && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \ apt-get clean && rm -rf /var/lib/apt/lists/* && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
RUN apt-get update && apt-get install -y --no-install-recommends RUN apt-key del 7fa2af80 && \
RUN apt-get install software-properties-common -y apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get install python3.8 -y RUN add-apt-repository ppa:deadsnakes/ppa && \
RUN apt-get install python3-pip -y apt-get install python3.10 python3.10-dev python3.10-venv python3-pip -y --no-install-recommends && \
RUN apt-get install python3.8-distutils -y apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get install python3.8-dev -y RUN pip install --upgrade pip && \
RUN apt-get install python3.8-venv -y pip install huggingface-hub && \
RUN python3.8 -m venv /venv pip install diffusers && \
ENV PATH=/venv/bin:$PATH pip install safetensors && \
pip install torch torchvision torchaudio --extra-index-url=https://download.pytorch.org/whl/cu116 && \
pip install bitsandbytes && \
pip install transformers accelerate xformers triton && \
pip install runpod
RUN python3.8 -m pip install --upgrade pip==23.0.1 RUN mkdir /workspace
RUN python3.8 -m pip install runpod==0.9.1 WORKDIR /workspace
RUN python3.8 -m pip install torch==2.0.0
RUN python3.8 -m pip install transformers==4.27.2
COPY model_fetcher.py /src/model_fetcher.py COPY model_fetcher.py /workspace/
RUN python3.8 model_fetcher.py --model_name=${MODEL_NAME} RUN python model_fetcher.py --model_name=${MODEL_NAME}
#RUN git lfs install && \
# git clone --depth 1 https://huggingface.co/${MODEL_NAME}
COPY runpod_infer.py /src/runpod_infer.py COPY runpod_infer.py /workspace/
COPY test_input.json /src/test_input.json COPY test_input.json /workspace/
CMD python3.8 -u runpod_infer.py --model_name=${MODEL_NAME} CMD python -u runpod_infer.py --model_name=${MODEL_NAME}

11
runpod/runpod-worker-transformers/README.md

@ -11,3 +11,14 @@ Select one of the following models to build:
```BASH ```BASH
docker build --build-arg MODEL_NAME={model name} -t repo/image_name:tag . docker build --build-arg MODEL_NAME={model name} -t repo/image_name:tag .
``` ```
```BASH
pip install --upgrade pip
git clone https://github.com/AlpinDale/gptq-gptj.git
cd gptq-gptj
pip install -r requirements.txt
CUDA_VISIBLE_DEVICES=0 python gptj.py PygmalionAI/pygmalion-6b c4 --wbits 4 --groupsize 128 --save pygmalion-6b-8bit-128g.pt
CUDA_VISIBLE_DEVICES=0 python gptj.py PygmalionAI/pygmalion-6b c4 --wbits 4 --groupsize 128 --save_safetensors pygmalion-6b-8bit-128g.safetensors
scp -P 22023 pygmalion-6b-8bit-128g.safetensors will@xd0.de:/home/will/
scp -P 22023 pygmalion-6b-8bit-128g.safetensors will@xd0.de:/home/will/
```

17
runpod/runpod-worker-transformers/model_fetcher.py

@ -38,15 +38,30 @@ def download_model(model_name):
AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B") AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
# ------------------------------ PPO Shygmalion 6B ----------------------------- # # ------------------------------ PPO Shygmalion 6B ----------------------------- #
elif model_name == 'shygmalion-6b': elif model_name == 'ppo-shygmalion-6b':
AutoModelForCausalLM.from_pretrained("TehVenom/PPO_Shygmalion-6b") AutoModelForCausalLM.from_pretrained("TehVenom/PPO_Shygmalion-6b")
AutoTokenizer.from_pretrained("TehVenom/PPO_Shygmalion-6b") AutoTokenizer.from_pretrained("TehVenom/PPO_Shygmalion-6b")
# ------------------------------ Dolly Shygmalion 6B ----------------------------- #
elif model_name == 'dolly-shygmalion-6b':
AutoModelForCausalLM.from_pretrained("TehVenom/Dolly_Shygmalion-6b")
AutoTokenizer.from_pretrained("TehVenom/Dolly_Shygmalion-6b")
# ------------------------------ Erebus 13B (NSFW) ----------------------------- # # ------------------------------ Erebus 13B (NSFW) ----------------------------- #
elif model_name == 'erebus-13b': elif model_name == 'erebus-13b':
AutoModelForCausalLM.from_pretrained("KoboldAI/OPT-13B-Erebus") AutoModelForCausalLM.from_pretrained("KoboldAI/OPT-13B-Erebus")
AutoTokenizer.from_pretrained("KoboldAI/OPT-13B-Erebus") AutoTokenizer.from_pretrained("KoboldAI/OPT-13B-Erebus")
# --------------------------- Alpaca 13B (Quantized) -------------------------- #
elif model_name == 'gpt4-x-alpaca-13b-native-4bit-128g':
AutoModelForCausalLM.from_pretrained("anon8231489123/gpt4-x-alpaca-13b-native-4bit-128g")
AutoTokenizer.from_pretrained("anon8231489123/gpt4-x-alpaca-13b-native-4bit-128g")
# --------------------------------- Alpaca 13B -------------------------------- #
elif model_name == 'gpt4-x-alpaca':
AutoModelForCausalLM.from_pretrained("chavinlo/gpt4-x-alpaca")
AutoTokenizer.from_pretrained("chavinlo/gpt4-x-alpaca")
# ---------------------------------------------------------------------------- # # ---------------------------------------------------------------------------- #
# Parse Arguments # # Parse Arguments #

23
runpod/runpod-worker-transformers/runpod_infer.py

@ -7,7 +7,8 @@ import torch
import runpod import runpod
from runpod.serverless.utils.rp_validator import validate from runpod.serverless.utils.rp_validator import validate
from transformers import (GPTNeoForCausalLM, GPT2Tokenizer, GPTNeoXForCausalLM, from transformers import (GPTNeoForCausalLM, GPT2Tokenizer, GPTNeoXForCausalLM,
GPTNeoXTokenizerFast, GPTJForCausalLM, AutoTokenizer, AutoModelForCausalLM) GPTNeoXTokenizerFast, GPTJForCausalLM, AutoTokenizer, AutoModelForCausalLM,
LlamaForCausalLM, LlamaTokenizer)
torch.cuda.is_available() torch.cuda.is_available()
@ -174,16 +175,34 @@ if __name__ == "__main__":
tokenizer = AutoTokenizer.from_pretrained( tokenizer = AutoTokenizer.from_pretrained(
"EleutherAI/gpt-j-6B", local_files_only=True) "EleutherAI/gpt-j-6B", local_files_only=True)
elif args.model_name == 'shygmalion-6b': elif args.model_name == 'ppo-shygmalion-6b':
model = AutoModelForCausalLM.from_pretrained( model = AutoModelForCausalLM.from_pretrained(
"TehVenom/PPO_Shygmalion-6b", local_files_only=True).to(device) "TehVenom/PPO_Shygmalion-6b", local_files_only=True).to(device)
tokenizer = AutoTokenizer.from_pretrained( tokenizer = AutoTokenizer.from_pretrained(
"TehVenom/PPO_Shygmalion-6b", local_files_only=True) "TehVenom/PPO_Shygmalion-6b", local_files_only=True)
elif args.model_name == 'dolly-shygmalion-6b':
model = AutoModelForCausalLM.from_pretrained(
"TehVenom/Dolly_Shygmalion-6b", local_files_only=True).to(device)
tokenizer = AutoTokenizer.from_pretrained(
"TehVenom/Dolly_Shygmalion-6b", local_files_only=True)
elif args.model_name == 'erebus-13b': elif args.model_name == 'erebus-13b':
model = AutoModelForCausalLM.from_pretrained( model = AutoModelForCausalLM.from_pretrained(
"KoboldAI/OPT-13B-Erebus", local_files_only=True).to(device) "KoboldAI/OPT-13B-Erebus", local_files_only=True).to(device)
tokenizer = AutoTokenizer.from_pretrained( tokenizer = AutoTokenizer.from_pretrained(
"KoboldAI/OPT-13B-Erebus", local_files_only=True) "KoboldAI/OPT-13B-Erebus", local_files_only=True)
elif args.model_name == 'gpt4-x-alpaca-13b-native-4bit-128g':
model = LlamaForCausalLM.from_pretrained(
"anon8231489123/gpt4-x-alpaca-13b-native-4bit-128g", local_files_only=True).to(device)
tokenizer = LlamaTokenizer.from_pretrained(
"anon8231489123/gpt4-x-alpaca-13b-native-4bit-128g", local_files_only=True)
elif args.model_name == 'gpt4-x-alpaca':
model = LlamaForCausalLM.from_pretrained(
"chavinlo/gpt4-x-alpaca", local_files_only=True).to(device)
tokenizer = LlamaTokenizer.from_pretrained(
"chavinlo/gpt4-x-alpaca", local_files_only=True)
runpod.serverless.start({"handler": generator}) runpod.serverless.start({"handler": generator})

Loading…
Cancel
Save