Skip to content

Commit

Permalink
Merge pull request #2 from noco-ai/v0.2.0
Browse files Browse the repository at this point in the history
V0.2.0
  • Loading branch information
noco-ai authored Dec 24, 2023
2 parents 17e8a52 + 24224fa commit 75f7f9d
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GOLEM_VAULT_HOST=http://10.23.82.2:8200
GOLEM_AMQP_HOST=10.23.82.4
GOLEM_ID=golem1
53 changes: 52 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ require ExLlama and a Nvidia Ampere or better GPU for real-time results.

These instructions should work to get the SpellBook framework up and running on Ubuntu 22. A Nvidia video card supported by ExLlama is required for routing.

- Default username: admin
- Default password: admin

### Docker Installation

```bash
Expand All @@ -35,6 +38,46 @@ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin
sudo groupadd docker
sudo usermod -aG docker $USER
sudo newgrp docker
sudo shutdown -r now
```

### Build and Start Containers (No GPU)

The docker-compose-nogpu.yml is useful for running the UI and middleware in a situation where you want another backend handling you GPUs and LLMs. For example
if you are also using Text Generation UI and do not want to mess with it settings this compose file can be used to just run the UI, allowing you then to then connect it to the endpoint provided by Oobabooga or any other OpenAI compatible backend.

```bash
docker compose -f docker-compose-nogpu.yml build
docker compose -f docker-compose-nogpu.yml up
```

### Build and Start Additional Workers (No GPU)

If you have more than one server you can run additional Elemental Golem workers to give the UI access to more resources. A few steps need to be taken on the
primary Spellbook server that is running the UI, middleware and other resources like Vault.

- Run these command on the primary server that is running the UI and middleware software in Docker.
- Copy the read token to a temp file to copy it to the worker server.
- Make note of the LAN IP address of the primary server. It is needed for the GOLEM_VAULT_HOST and GOLEM_VAULT_HOST variables.
- Make sure ports for RabbitMQ and Vault are open.

```bash
sudo more /var/lib/docker/volumes/spellbook-docker_vault_share/_data/read-token
ip address
sudo ufw allow 5671
sudo ufw allow 5672
sudo ufw allow 8200
```

- Run these command on the server running the worker. The GOLEM_ID needs to be unique for every server and golem1 is used by the primary.
- The first time you run the container it will timeout, git CTL + C or wait then copy the Vault token.
```bash
docker compose -f docker-compose-worker-nogpu.yml build
GOLEM_VAULT_HOST=10.10.10.X GOLEM_AMQP_HOST=10.10.10.X GOLEM_ID=golem2 docker compose -f docker-compose-worker-nogpu.yml up
sudo su
echo "TOKEN FROM PRIMARY SERVER" > /var/lib/docker/volumes/spellbook-docker_vault_share/_data/read-token
exit
GOLEM_VAULT_HOST=10.10.10.X GOLEM_AMQP_HOST=10.10.10.X GOLEM_ID=golem2 docker compose -f docker-compose-worker-nogpu.yml up
```

### Nvidia Driver Installation
Expand Down Expand Up @@ -71,9 +114,17 @@ sudo systemctl restart docker
sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi
```

### Build and Start Containers
### Build and Start Containers (Nvidia GPU)

```bash
docker compose build
docker compose up
```

### Build and Start Additional Workers (Nvidia GPU)

Follow the directions under the *Build and Start Additional Workers (No GPU)* section substituting the build and up lines for the ones found below.
```bash
docker compose -f docker-compose-worker.yml build
GOLEM_VAULT_HOST=10.10.10.X GOLEM_AMQP_HOST=10.10.10.X GOLEM_ID=golem2 docker compose -f docker-compose-worker.yml up
```
7 changes: 3 additions & 4 deletions arcane-bridge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ RUN mkdir -p /etc/apt/keyrings && \
RUN groupadd -r arcane && useradd -r -m -g arcane arcane && \
mkdir -p /app && chown arcane:arcane /app
WORKDIR /app
RUN echo "Installing 0.1.0 of Arcane Bridge"
RUN git clone https://github.com/noco-ai/arcane-bridge.git /app
RUN echo "Installing 0.2.0 of Arcane Bridge"
RUN git clone --depth 1 --branch v0.2.0 https://github.com/noco-ai/arcane-bridge.git /app
RUN chown -R arcane:arcane /app
ENV NPM_CONFIG_PREFIX=/app/.npm-global
ENV PATH=$PATH:/app/.npm-global/bin
USER arcane
RUN npm install && npm run compile

CMD ["npm", "run", "start", "--", "-vh", "http://10.23.82.2:8200", "-vt", "/vault_share/write-token"]
CMD ["npm", "run", "start", "--", "-vh", "http://10.23.82.2:8200", "-vt", "/vault_share/write-token", "-cs"]
# CMD tail -f /dev/null
# npm run start -- -vh http://10.23.82.2:8200 -vt /vault_share/write-token
111 changes: 111 additions & 0 deletions docker-compose-nogpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
version: "3.8"

services:
vault:
build:
dockerfile: vault/Dockerfile
container_name: spellbook_vault
ports:
- "8200:8200"
environment:
VAULT_ADDR: http://0.0.0.0:8200
volumes:
- vault_share:/vault_share
cap_add:
- IPC_LOCK
networks:
spellbook-net:
ipv4_address: 10.23.82.2

mariadb:
build:
dockerfile: mariadb/Dockerfile
container_name: spellbook_mariadb
environment:
MARIADB_ROOT_PASSWORD: "spellBOOK.temp.321"
MARIADB_DATABASE: "spellbook"
volumes:
- vault_share:/vault_share
ports:
- "3306:3306"
depends_on:
- vault
networks:
spellbook-net:
ipv4_address: 10.23.82.3

spellbook_ui:
build:
dockerfile: spellbook/Dockerfile
container_name: spellbook_ui
volumes:
- vault_share:/vault_share
ports:
- "4200:4200"
depends_on:
- vault
- mariadb
- rabbitmq
networks:
spellbook-net:
ipv4_address: 10.23.82.6

arcane_bridge:
build:
dockerfile: arcane-bridge/Dockerfile
container_name: spellbook_arcane_bridge
volumes:
- vault_share:/vault_share
ports:
- "3000:3000"
depends_on:
- vault
- mariadb
- rabbitmq
networks:
spellbook-net:
ipv4_address: 10.23.82.7

golem:
build:
dockerfile: elemental-golem/Dockerfile-nogpu
container_name: spellbook_golem
environment:
- GOLEM_ID=${GOLEM_ID}
- GOLEM_AMQP_HOST=${GOLEM_AMQP_HOST}
- GOLEM_VAULT_HOST=${GOLEM_VAULT_HOST}
volumes:
- vault_share:/vault_share
- models_share:/server/data
depends_on:
- vault
- rabbitmq
networks:
spellbook-net:
ipv4_address: 10.23.82.5

rabbitmq:
build:
dockerfile: rabbitmq/Dockerfile
container_name: spellbook_rabbitmq
depends_on:
- vault
ports:
- "15672:15672"
- "5672:5672"
- "5671:5671"
volumes:
- vault_share:/vault_share
networks:
spellbook-net:
ipv4_address: 10.23.82.4

volumes:
vault_share:
models_share:

networks:
spellbook-net:
ipam:
config:
- subnet: 10.23.82.0/16
28 changes: 28 additions & 0 deletions docker-compose-worker-nogpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: "3.8"

services:

golem:
build:
dockerfile: elemental-golem/Dockerfile-nogpu
container_name: spellbook_golem_nogpu
volumes:
- vault_share:/vault_share
- models_share:/server/data
environment:
- GOLEM_ID=${GOLEM_ID}
- GOLEM_AMQP_HOST=${GOLEM_AMQP_HOST}
- GOLEM_VAULT_HOST=${GOLEM_VAULT_HOST}
networks:
spellbook-net:
ipv4_address: 10.23.82.5

volumes:
vault_share:
models_share:

networks:
spellbook-net:
ipam:
config:
- subnet: 10.23.82.0/16
35 changes: 35 additions & 0 deletions docker-compose-worker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.8"

services:

golem:
build:
dockerfile: elemental-golem/Dockerfile
container_name: spellbook_golem
volumes:
- vault_share:/vault_share
- models_share:/server/data
environment:
- GOLEM_ID=${GOLEM_ID}
- GOLEM_AMQP_HOST=${GOLEM_AMQP_HOST}
- GOLEM_VAULT_HOST=${GOLEM_VAULT_HOST}
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
networks:
spellbook-net:
ipv4_address: 10.23.82.5

volumes:
vault_share:
models_share:

networks:
spellbook-net:
ipam:
config:
- subnet: 10.23.82.0/16
12 changes: 9 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: "3.8"

services:
vault:
build:
Expand Down Expand Up @@ -68,11 +68,15 @@ services:

golem:
build:
dockerfile: elemental-golem/Dockerfile
container_name: spellbook_golem
dockerfile: elemental-golem/Dockerfile
container_name: spellbook_golem
volumes:
- vault_share:/vault_share
- models_share:/server/data
environment:
- GOLEM_ID=${GOLEM_ID}
- GOLEM_AMQP_HOST=${GOLEM_AMQP_HOST}
- GOLEM_VAULT_HOST=${GOLEM_VAULT_HOST}
depends_on:
- vault
- rabbitmq
Expand All @@ -95,6 +99,8 @@ services:
- vault
ports:
- "15672:15672"
- "5672:5672"
- "5671:5671"
volumes:
- vault_share:/vault_share
networks:
Expand Down
6 changes: 3 additions & 3 deletions elemental-golem/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ ENV LLAMA_CUBLAS=1
RUN groupadd -r golem && useradd -r -m -g golem golem && mkdir /server && chown -R golem:golem /server
RUN python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette pydantic-settings starlette-context
RUN CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
RUN echo "Installing v0.1.0 of Elemental Golem"
RUN git clone https://github.com/noco-ai/elemental-golem.git /server
RUN echo "Installing v0.2.1 of Elemental Golem"
RUN git clone --depth 1 --branch v0.2.1 https://github.com/noco-ai/elemental-golem.git /server
RUN pip install -r /server/requirements.txt
RUN mkdir -p /server/data/loras/
WORKDIR /server
CMD ["python3", "server.py", "--server-id", "golem1", "--vault-host", "http://10.23.82.2:8200", "--vault-token-file", "/vault_share/read-token", "--vault-root", "spellbook", "--shared-models", "true"]
CMD python3 server.py --server-id $GOLEM_ID --amqp-ip $GOLEM_AMQP_HOST --vault-host $GOLEM_VAULT_HOST --vault-token-file /vault_share/read-token --vault-root spellbook --shared-models true
# CMD tail -f /dev/null
# python3 server.py --server-id golem1 --vault-host http://10.23.82.2:8200 --vault-token-file /vault_share/read-token --vault-root spellbook --shared-models true
20 changes: 20 additions & 0 deletions elemental-golem/Dockerfile-nogpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:22.04

RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y git build-essential \
python3 python3-pip gcc tar wget \
ocl-icd-opencl-dev opencl-headers clinfo

COPY . .
RUN groupadd -r golem && useradd -r -m -g golem golem && mkdir /server && chown -R golem:golem /server
RUN python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette pydantic-settings starlette-context
RUN pip install llama-cpp-python
RUN echo "Installing v0.2.1 of Elemental Golem"
RUN git clone --depth 1 --branch v0.2.1 https://github.com/noco-ai/elemental-golem.git /server
RUN pip install -r /server/requirements-nogpu.txt
RUN mkdir -p /server/data/loras/
WORKDIR /server
CMD python3 server.py --server-id $GOLEM_ID --amqp-ip $GOLEM_AMQP_HOST --vault-host $GOLEM_VAULT_HOST --vault-token-file /vault_share/read-token --vault-root spellbook --shared-models true --gpu-type nogpu
# CMD tail -f /dev/null
# python3 server.py --server-id golem1 --vault-host http://10.23.82.2:8200 --vault-token-file /vault_share/read-token --vault-root spellbook --shared-models true
#CMD ["python3", "server.py", "--server-id", "$GOLEM_ID", "--amqp-ip", "$AMQP_IP", "--vault-host", "$VAULT_HOST", "--vault-token-file", "/vault_share/read-token", "--vault-root", "spellbook", "--shared-models", "true", "--gpu-type", "nogpu"]
10 changes: 8 additions & 2 deletions mariadb/spellbook.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,20 @@ DROP TABLE IF EXISTS `chat_conversation`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `chat_conversation` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL,
`is_private` tinyint(1) NOT NULL,
`is_shared` tinyint(1) NOT NULL,
`system_message` text COLLATE utf8mb4_unicode_ci,
`use_model` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`topic` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`seed` int(10) DEFAULT '-1',
`seed` bigint(10) DEFAULT '-1',
`temperature` float DEFAULT '1',
`top_k` float DEFAULT '0.9',
`top_k` int(10) DEFAULT 50,
`top_p` float DEFAULT '0.9',
`min_p` float DEFAULT '0.05',
`mirostat` int(10) DEFAULT 0,
`mirostat_tau` float DEFAULT '5.0',
`mirostat_eta` float DEFAULT '0.1',
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`locked` int(10) unsigned DEFAULT '0',
Expand All @@ -65,6 +70,7 @@ DROP TABLE IF EXISTS `chat_conversation_message`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `chat_conversation_message` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`role` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`conversation_id` int(10) unsigned NOT NULL,
Expand Down
4 changes: 2 additions & 2 deletions spellbook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesourc
RUN apt-get update
RUN apt-get install nodejs -y
RUN npm install -g @angular/cli@latest
RUN echo "Install v0.1.0 of Spellbook UI"
RUN git clone https://github.com/noco-ai/spellbook-ui.git /app
RUN echo "Install v0.2.0 of Spellbook UI"
RUN git clone --depth 1 --branch v0.2.0 https://github.com/noco-ai/spellbook-ui.git /app
WORKDIR /app
RUN npm install
ADD spellbook/environment.ts /app/environments/environment.ts
Expand Down

0 comments on commit 75f7f9d

Please sign in to comment.