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

Develop #24

Merged
merged 8 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.github
.idea
lib
dist
build
27 changes: 0 additions & 27 deletions .github/workflows/build.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/repository-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Linux Build

on:
release:
types: [ published ]
workflow_dispatch:

env:
DOCKER_IMAGE: ghcr.io/capsize-games/chatai/chatai:linux
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
CR_PAT: ${{ secrets.CR_PAT }}
CR_REPO: ${{ secrets.CR_REPO }}
CR_USERNAME: ${{ secrets.CR_USERNAME }}

jobs:
run-chatai:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Run chatai on Linux
run: |
docker pull $DOCKER_IMAGE
docker run --rm \
-e BUTLER_API_KEY=${{ secrets.BUTLER_API_KEY }} \
-e ITCHIO_USERNAME=${{ secrets.ITCHIO_USERNAME }} \
-e DEV_ENV=0 \
-e AIRUNNER_ENVIRONMENT=prod \
-e AIRUNNER_OS=linux \
-e PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 \
-e NUMBA_CACHE_DIR=/tmp/numba_cache \
-e DISABLE_TELEMETRY=1 \
-e TCL_LIBDIR_PATH=/usr/lib/x86_64-linux-gnu/ \
-e TK_LIBDIR_PATH=/usr/lib/x86_64-linux-gnu/ \
ghcr.io/capsize-games/chatai/chatai:linux bash build.sh
82 changes: 82 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
FROM ubuntu:latest as base_image
USER root
ENV TZ=America/Denver
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& apt-get update \
&& apt-get upgrade -y \
&& apt install software-properties-common -y \
&& add-apt-repository ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& dpkg --add-architecture i386 \
&& apt-get update \
&& apt install libtinfo6 -y \
&& apt-get install -y git \
&& apt-get install -y wget \
&& apt-get install -y curl \
&& apt-get install -y vim \
&& apt-get install -y software-properties-common \
&& apt-get install -y gcc-9 \
&& apt-get install -y g++-9 \
&& apt-get install -y bash \
&& apt-get install -y build-essential \
&& apt-get install -y libssl-dev \
&& apt-get install -y libffi-dev \
&& apt-get install -y libgl1-mesa-dev \
&& apt-get install -y nvidia-cuda-toolkit \
&& apt-get install -y xclip \
&& apt-get install -y libjpeg-dev \
&& apt-get install -y zlib1g-dev \
&& apt-get install -y libpng-dev \
&& apt-get install software-properties-common -y \
&& apt-get install patchelf -y \
&& add-apt-repository ppa:deadsnakes/ppa -y \
&& apt update \
&& apt install python3.10 -y \
&& apt install python3.10-distutils -y \
&& apt install python3-pip -y \
&& apt install python3.10-tk -y \
&& apt install -y upx \
&& apt-get install patchelf -y \
&& apt-get install ccache -y \
&& apt-get install -y libxcb-xinerama0 \
&& apt-get install -y libgtk-3-0 \
&& apt-get install qt6-qpa-plugins -y \
&& apt-get install libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-dev libxcb-xinerama0 -y \
&& apt-get install -y qt6-base-dev \
&& rm -rf /var/lib/apt/lists/ \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 \
&& rm -rf /var/lib/apt/lists/*

FROM base_image as install_requirements
USER root
WORKDIR /app
ENV XFORMERS_MORE_DETAILS=1
RUN pip install nvidia-pyindex
WORKDIR /app
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools
RUN pip install --upgrade wheel
RUN pip install aihandler
RUN pip install accelerate
RUN pip install requests

FROM install_requirements as fix_tcl
USER root
RUN ln -s /usr/share/tcltk/tcl8.6 /usr/share/tcltk/tcl8

FROM fix_tcl as install_apps
COPY build.sh build.sh
COPY build.py build.py
COPY build.chatai.linux.prod.spec build.chatai.linux.prod.spec
COPY linux.itch.toml linux.itch.toml
COPY src/chatairunner/v1.yaml v1.yaml
COPY src/chatairunner/v2.yaml v2.yaml
COPY src/chatairunner/pyqt src/chatairunner/pyqt
RUN python3 -c "from accelerate.utils import write_basic_config; write_basic_config(mixed_precision='fp16')"
RUN pip uninstall nvidia-cublas-cu11 -y

FROM install_apps as more_env
ENV PATH="/usr/local/lib/python3.10:/usr/local/lib/python3.10/bin:${PATH}"
ENV PYTHONPATH="/usr/local/lib/python3.10:/usr/local/lib/python3.10/bin:${PYTHONPATH}"
RUN pip install pyinstaller
RUN pip install bitsandbytes-cuda102
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,59 @@ to and from an active Google T5-Flan model.
- Python 3.10.6
- pip-23.0.1

---

### Docker

[Current builds of AI Runner are compiled with pyinstaller on docker.](https://github.com/Capsize-Games/airunner/pkgs/container/airunner%2Fairunner)

**Pull Docker container from repo**

Linux
```
docker pull ghcr.io/capsize-games/chatai/chatai:linux
```

Windows
```
docker pull ghcr.io/capsize-games/chatai/chatai:windows
```

**Build Docker**

Linux
```
docker-compose -f docker-compose.yml build
docker tag ghcr.io/capsize-games/chatai/chatai:linux ghcr.io/capsize-games/chatai/chatai:linux
docker push ghcr.io/capsize-games/chatai/chatai:linux
```

Windows
```
docker-compose -f docker-compose.windows.yml build
docker tag ghcr.io/capsize-games/chatai/chatai:linux ghcr.io/capsize-games/chatai/chatai:windows
docker push ghcr.io/capsize-games/chatai/chatai:windows
```

**Run the app using Docker**
```
docker-compose run linux python3 /app/main.py
```

**Build latest version** of AI Runner using Docker locally - this will output a `build` and `dist` folder on your machine.
```
docker run --rm -v $(pwd)/dist:/app/dist -v $(pwd)/build:/app/build ghcr.io/capsize-games/chatai/chatai:linux bash build.sh

docker run --rm -m 24g --cpus=12 -v $(pwd)/dist:/app/dist -v $(pwd)/build:/app/build ghcr.io/capsize-games/chatai/chatai:windows bash build.windows.sh
```

```
docker tag ghcr.io/capsize-games/chatai/chatai:linux ghcr.io/capsize-games/chatai/chatai:windows
docker push ghcr.io/capsize-games/chatai/chatai:windows
``

---

#### Pypi installation

Use this installation method if you intend to use Chat AI from the command line or with
Expand All @@ -40,15 +93,15 @@ Windows
```
pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cu117
pip install aihandlerwindows
pip install https://github.com/w4ffl35/diffusers/archive/refs/tags/v0.14.0.ckpt_fix.tar.gz
pip install https://github.com/w4ffl35/diffusers/archive/refs/tags/v0.14.0.ckpt_fix_0.0.1.tar.gz
pip install https://github.com/w4ffl35/transformers/archive/refs/tags/tensor_fix-v1.0.2.tar.gz
pip install https://github.com/acpopescu/bitsandbytes/releases/download/v0.37.2-win.0/bitsandbytes-0.37.2-py3-none-any.whl
pip install chatai --no-deps
```

Linux
```
pip install https://github.com/w4ffl35/diffusers/archive/refs/tags/v0.14.0.ckpt_fix.tar.gz
pip install https://github.com/w4ffl35/diffusers/archive/refs/tags/v0.14.0.ckpt_fix_0.0.1.tar.gz
pip install https://github.com/w4ffl35/transformers/archive/refs/tags/tensor_fix-v1.0.2.tar.gz
pip install chatairunner
```
Expand Down
Loading