Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/h2oai/h2ogpt
Browse files Browse the repository at this point in the history
  • Loading branch information
Mins0o committed Dec 5, 2023
2 parents c1b4bf8 + 8a333e2 commit d2a3c3c
Show file tree
Hide file tree
Showing 180 changed files with 29,795 additions and 4,993 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
.dockerignore
.pytest_cache
.cache
.local
.github
.nv
.benchmarks
.bash_history
.gitignore
h2ogpt.egg-info
venv
build
dist
prebuilt_deps
Dockerfile
17 changes: 17 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# H2OGPT

H2OGPT_PORT=7860
H2OGPT_RUNTIME=gcr.io/vorvan/h2oai/h2ogpt-runtime:0.1.0
H2OGPT_BASE_MODEL=h2oai/h2ogpt-4096-llama2-7b-chat
H2OGPT_ARGS="/workspace/generate.py --base_model=${H2OGPT_BASE_MODEL} --use_safetensors=True --prompt_type=llama2 --save_dir=/workspace/save/ --use_gpu_id=False --score_model=None --max_max_new_tokens=2048 --max_new_tokens=1024"

# VLLM

VLLM_TOKENIZER=hf-internal-testing/llama-tokenizer
H2OGPT_VLLM_ARGS="--model=${H2OGPT_BASE_MODEL} --tokenizer=${VLLM_TOKENIZER} --tensor-parallel-size=2 --seed=1234 --trust-remote-code --download-dir=/workspace/.cache/huggingface/hub"

# CPU models

MODEL_PATH_LLAMA=https://huggingface.co/TheBloke/Llama-2-7b-Chat-GGUF/resolve/main/llama-2-7b-chat.Q6_K.gguf
H2OGPT_CPU_ARGS="/workspace/generate.py --base_model=llama --model_path_llama=${MODEL_PATH_LLAMA} --max_seq_len=4096"
6 changes: 3 additions & 3 deletions .github/workflows/python-package-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ jobs:
run: |
python3.10 -m pip install --upgrade pip
python3.10 -m pip install setuptools wheel twine --upgrade
- name: Build Wheel
run: make clean dist
- name: Modify Version
if: ${{ inputs.version != ''}}
run: |
echo ${{ inputs.version}} > version.txt
echo "h2ogpt-wheel-version = $(cat version.txt)"
- name: Build Wheel
run: make clean dist

- name: Publish to Test-PyPI
if: ${{ inputs.pypi-index == 'Test-PyPI' }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ Dockerfile_deps

# virtual envs
venv

# Mac one click installer
Tesseract-OCR/
poppler/
78 changes: 11 additions & 67 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,90 +1,34 @@
# devel needed for bitsandbytes requirement of libcudart.so, otherwise runtime sufficient
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
git \
curl \
wget \
software-properties-common \
pandoc
ENV DEBIAN_FRONTEND=noninteractive

ENV PATH="/h2ogpt_conda/bin:${PATH}"
ARG PATH="/h2ogpt_conda/bin:${PATH}"

RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Linux-x86_64.sh && \
mkdir -p h2ogpt_conda && \
bash ./Miniconda3-py310_23.1.0-1-Linux-x86_64.sh -b -u -p /h2ogpt_conda && \
conda install python=3.10 pygobject weasyprint -c conda-forge -y

WORKDIR /workspace

RUN apt-get install -y libmagic-dev poppler-utils tesseract-ocr libtesseract-dev libreoffice autoconf libtool

COPY requirements.txt requirements.txt
COPY reqs_optional reqs_optional

RUN python3.10 -m pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118
RUN python3.10 -m pip install -r reqs_optional/requirements_optional_langchain.txt --extra-index-url https://download.pytorch.org/whl/cu118
RUN python3.10 -m pip install -r reqs_optional/requirements_optional_gpt4all.txt --extra-index-url https://download.pytorch.org/whl/cu118
RUN python3.10 -m pip install -r reqs_optional/requirements_optional_langchain.gpllike.txt --extra-index-url https://download.pytorch.org/whl/cu118
RUN python3.10 -m pip install -r reqs_optional/requirements_optional_langchain.urls.txt --extra-index-url https://download.pytorch.org/whl/cu118
RUN python3.10 -m pip install -r reqs_optional/requirements_optional_faiss_cpu.txt --extra-index-url https://download.pytorch.org/whl/cu118

RUN python3.10 -m pip install -r reqs_optional/requirements_optional_doctr.txt --extra-index-url https://download.pytorch.org/whl/cu118
# go back to older onnx so Tesseract OCR still works
RUN python3.10 -m pip install onnxruntime==1.15.0 onnxruntime-gpu==1.15.0 --extra-index-url https://download.pytorch.org/whl/cu118 && \
python3.10 -m pip uninstall -y weasyprint && \
python3.10 -m pip install weasyprint

ENV HOME=/workspace
ENV CUDA_HOME=/usr/local/cuda-11.8

# Install prebuilt dependencies

RUN python3.10 -m nltk.downloader all
RUN python3.10 -m pip install https://github.com/PanQiWei/AutoGPTQ/releases/download/v0.4.2/auto_gptq-0.4.2+cu118-cp310-cp310-linux_x86_64.whl
RUN python3.10 -m pip install https://github.com/jllllll/llama-cpp-python-cuBLAS-wheels/releases/download/textgen-webui/llama_cpp_python_cuda-0.1.73+cu118-cp310-cp310-linux_x86_64.whl
RUN python3.10 -m pip install https://github.com/jllllll/exllama/releases/download/0.0.13/exllama-0.0.13+cu118-cp310-cp310-linux_x86_64.whl --no-cache-dir
RUN playwright install --with-deps

COPY . .

ENV VLLM_CACHE=/workspace/.vllm_cache
ENV TIKTOKEN_CACHE_DIR=/workspace/tiktoken_cache

RUN sp=`python3.10 -c 'import site; print(site.getsitepackages()[0])'` && sed -i 's/posthog\.capture/return\n posthog.capture/' $sp/chromadb/telemetry/posthog.py
# RUN sp=`python3.10 -c 'import site; print(site.getsitepackages()[0])'` && \
# sed -i 's/posthog\.capture/return\n posthog.capture/' $sp/chromadb/telemetry/posthog.py && \
# cd $sp && \
# rm -rf openai_vllm* && \
# cp -a openai openai_vllm && \
# cp -a openai-0.27.8.dist-info openai_vllm-0.27.8.dist-info && \
# find openai_vllm -name '*.py' | xargs sed -i 's/from openai /from openai_vllm /g' && \
# find openai_vllm -name '*.py' | xargs sed -i 's/openai\./openai_vllm./g' && \
# find openai_vllm -name '*.py' | xargs sed -i 's/from openai\./from openai_vllm./g' && \
# find openai_vllm -name '*.py' | xargs sed -i 's/import openai/import openai_vllm/g' && \
# conda create -n vllm python=3.10 -y && \
# /h2ogpt_conda/envs/vllm/bin/python3.10 -m pip install vllm ray pandas --extra-index-url https://download.pytorch.org/whl/cu118 && \
# mkdir ${VLLM_CACHE}
WORKDIR /workspace

EXPOSE 8888
EXPOSE 7860
EXPOSE 5000
COPY . /workspace/

# /workspace/.cache is the equivalent to ~/.cache
ENV HOME=/workspace
RUN cd /workspace && ./docker_build_script_ubuntu.sh

COPY build_info.txt* /build_info.txt
RUN touch /build_info.txt
RUN chmod -R a+rwx /workspace

ARG user=h2ogpt
ARG group=h2ogpt
ARG uid=1000
ARG gid=1000

RUN groupadd -g ${gid} ${group} && useradd -u ${uid} -g ${group} -s /bin/bash ${user}
RUN chmod -R a+rwx /workspace
RUN chmod -R a+rwx /h2ogpt_conda

EXPOSE 8888
EXPOSE 7860
EXPOSE 5000

USER h2ogpt

Expand Down
46 changes: 37 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
all: clean dist

PACKAGE_VERSION := `cat version.txt | tr -d '\n'`
BUILD_TAG_FILES := requirements.txt Dockerfile `ls reqs_optional/*.txt | sort`
BUILD_TAG := $(shell md5sum $(BUILD_TAG_FILES) 2> /dev/null | sort | md5sum | cut -d' ' -f1)
BUILD_TAG := $(shell git describe --always --dirty)
DOCKER_TEST_IMAGE := harbor.h2o.ai/h2ogpt/test-image:$(BUILD_TAG)
PYTHON_BINARY ?= `which python`
DEFAULT_MARKERS ?= "not need_tokens and not need_gpu"
Expand Down Expand Up @@ -47,18 +46,44 @@ build_info.txt:

# Deprecated for now, no 0.4.1 on pypi, use release binary wheel that has no CUDA errors anymore
docker_build_deps:
@rm -rf Dockerfile_deps
@sed '/# Install prebuilt dependencies/,$$d' Dockerfile > Dockerfile_deps
@docker build -t h2ogpt-deps-builder -f Dockerfile_deps .
@cp docker_build_script_ubuntu.sh docker_build_script_ubuntu.sh.back
@sed -i '/# Install prebuilt dependencies/,$$d' docker_build_script_ubuntu.sh
@docker build -t h2ogpt-deps-builder -f Dockerfile .
@mv docker_build_script_ubuntu.sh.back docker_build_script_ubuntu.sh
@mkdir -p prebuilt_deps
@docker run \
--rm -it --entrypoint bash --runtime nvidia -v `pwd`:/dot \
h2ogpt-deps-builder -c " \
--rm \
-it \
--entrypoint bash \
--runtime nvidia \
-v `pwd`:/dot \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-u `id -u`:`id -g` \
h2ogpt-deps-builder -c " \
mkdir -p /dot/prebuilt_deps && cd /dot/prebuilt_deps && \
GITHUB_ACTIONS=true python3.10 -m pip install auto-gptq==0.4.2 --no-cache-dir --use-deprecated=legacy-resolver && \
python3.10 -m pip wheel auto-gptq==0.4.2 \
"
s3cmd put prebuilt_deps/auto_gptq-0.4.2-cp310-cp310-linux_x86_64.whl s3://artifacts.h2o.ai/deps/h2ogpt/ && \
s3cmd setacl s3://artifacts.h2o.ai/deps/h2ogpt/auto_gptq-0.4.2-cp310-cp310-linux_x86_64.whl --acl-public
@docker run \
--rm \
-it \
--entrypoint bash \
-v `pwd`:/dot \
quay.io/pypa/manylinux2014_x86_64 -c " \
ln -s /usr/local/bin/python3.10 /usr/local/bin/python3 && cd /tmp && \
git clone https://github.com/h2oai/duckdb.git && \
cd duckdb && \
git checkout dcd8c1ffc53dd020623630efb99ba6a3a4cbc5ad && \
BUILD_PYTHON=1 make release && \
cd tools/pythonpkg && \
python3.10 setup.py bdist_wheel && \
cp dist/duckdb-0.*.whl /dot/prebuilt_deps \
"
s3cmd put prebuilt_deps/auto_gptq-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl s3://artifacts.h2o.ai/deps/h2ogpt/ && \
s3cmd setacl s3://artifacts.h2o.ai/deps/h2ogpt/auto_gptq-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl --acl-public
s3cmd put prebuilt_deps/duckdb-0.8.2.dev4026+gdcd8c1ffc5-cp310-cp310-linux_x86_64.whl s3://artifacts.h2o.ai/deps/h2ogpt/ && \
s3cmd setacl s3://artifacts.h2o.ai/deps/h2ogpt/duckdb-0.8.2.dev4026+gdcd8c1ffc5-cp310-cp310-linux_x86_64.whl --acl-public

docker_build: build_info.txt
ifeq ($(shell curl --connect-timeout 4 --write-out %{http_code} -sS --output /dev/null -X GET http://harbor.h2o.ai/api/v2.0/projects/h2ogpt/repositories/test-image/artifacts/$(BUILD_TAG)/tags),200)
Expand All @@ -68,6 +93,9 @@ else
docker push $(DOCKER_TEST_IMAGE)
endif

just_docker_build: build_info.txt
DOCKER_BUILDKIT=1 docker build -t $(DOCKER_TEST_IMAGE) -f Dockerfile .

docker_build_runner: docker_build
-docker pull $(DOCKER_TEST_IMAGE)
docker tag $(DOCKER_TEST_IMAGE) gcr.io/vorvan/h2oai/h2ogpt-runtime:$(BUILD_TAG)
Expand Down
Binary file added MeIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d2a3c3c

Please sign in to comment.