-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VisualQnA docker for both Gaudi and Xeon using TGI serving (#547)
* Add VisualQnA docker for both Gaudi and Xeon Signed-off-by: lvliang-intel <liang1.lv@intel.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update token length Signed-off-by: lvliang-intel <liang1.lv@intel.com> --------- Signed-off-by: lvliang-intel <liang1.lv@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
02a1536
commit 2390920
Showing
9 changed files
with
595 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
FROM python:3.11-slim | ||
|
||
RUN apt-get update -y && apt-get install -y --no-install-recommends --fix-missing \ | ||
libgl1-mesa-glx \ | ||
libjemalloc-dev \ | ||
vim \ | ||
git | ||
|
||
RUN useradd -m -s /bin/bash user && \ | ||
mkdir -p /home/user && \ | ||
chown -R user /home/user/ | ||
|
||
WORKDIR /home/user/ | ||
RUN git clone https://github.com/opea-project/GenAIComps.git | ||
|
||
WORKDIR /home/user/GenAIComps | ||
RUN pip install --no-cache-dir --upgrade pip && \ | ||
pip install --no-cache-dir -r /home/user/GenAIComps/requirements.txt | ||
|
||
COPY ./visualqna.py /home/user/visualqna.py | ||
|
||
ENV PYTHONPATH=$PYTHONPATH:/home/user/GenAIComps | ||
|
||
USER user | ||
|
||
WORKDIR /home/user | ||
|
||
ENTRYPOINT ["python", "visualqna.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# Build MegaService of VisualQnA on Gaudi | ||
|
||
This document outlines the deployment process for a VisualQnA application utilizing the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline on Intel Gaudi server. The steps include Docker image creation, container deployment via Docker Compose, and service execution to integrate microservices such as llm. We will publish the Docker images to Docker Hub, it will simplify the deployment process for this service. | ||
|
||
## 🚀 Build Docker Images | ||
|
||
First of all, you need to build Docker Images locally. This step can be ignored after the Docker images published to Docker hub. | ||
|
||
### 1. Source Code install GenAIComps | ||
|
||
```bash | ||
git clone https://github.com/opea-project/GenAIComps.git | ||
cd GenAIComps | ||
``` | ||
|
||
### 2. Build LLM Image | ||
|
||
```bash | ||
docker build --no-cache -t opea/lvm-tgi:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/lvms/Dockerfile_tgi . | ||
``` | ||
|
||
### 3. Build TGI Gaudi Image | ||
|
||
Since TGI Gaudi has not supported llava-next in main branch, we'll need to build it from a PR branch for now. | ||
|
||
```bash | ||
git clone https://github.com/yuanwu2017/tgi-gaudi.git | ||
cd tgi-gaudi/ | ||
git checkout v2.0.4 | ||
docker build -t opea/llava-tgi:latest . | ||
cd ../ | ||
``` | ||
|
||
### 4. Build MegaService Docker Image | ||
|
||
To construct the Mega Service, we utilize the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline within the `visuralqna.py` Python script. Build the MegaService Docker image using the command below: | ||
|
||
```bash | ||
git clone https://github.com/opea-project/GenAIExamples.git | ||
cd GenAIExamples/VisualQnA/docker | ||
docker build --no-cache -t opea/visualqna:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile . | ||
cd ../../.. | ||
``` | ||
|
||
### 5. Build UI Docker Image | ||
|
||
Build frontend Docker image via below command: | ||
|
||
```bash | ||
cd GenAIExamples/VisualQnA/docker/ui/ | ||
docker build --no-cache -t opea/visualqna-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile . | ||
cd ../../../.. | ||
``` | ||
|
||
Then run the command `docker images`, you will have the following 4 Docker Images: | ||
|
||
1. `opea/llava-tgi:latest` | ||
2. `opea/lvm-tgi:latest` | ||
3. `opea/visualqna:latest` | ||
4. `opea/visualqna-ui:latest` | ||
|
||
## 🚀 Start MicroServices and MegaService | ||
|
||
### Setup Environment Variables | ||
|
||
Since the `compose.yaml` will consume some environment variables, you need to setup them in advance as below. | ||
|
||
```bash | ||
export no_proxy=${your_no_proxy} | ||
export http_proxy=${your_http_proxy} | ||
export https_proxy=${your_http_proxy} | ||
export LVM_MODEL_ID="llava-hf/llava-v1.6-mistral-7b-hf" | ||
export LVM_ENDPOINT="http://${host_ip}:8399" | ||
export LVM_SERVICE_PORT=9399 | ||
export MEGA_SERVICE_HOST_IP=${host_ip} | ||
export LVM_SERVICE_HOST_IP=${host_ip} | ||
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8888/v1/visualqna" | ||
``` | ||
|
||
Note: Please replace with `host_ip` with you external IP address, do **NOT** use localhost. | ||
|
||
### Start all the services Docker Containers | ||
|
||
```bash | ||
cd GenAIExamples/VisualQnA/docker/gaudi/ | ||
``` | ||
|
||
```bash | ||
docker compose -f compose.yaml up -d | ||
``` | ||
|
||
> **_NOTE:_** Users need at least one Gaudi cards to run the VisualQnA successfully. | ||
### Validate MicroServices and MegaService | ||
|
||
Follow the instructions to validate MicroServices. | ||
|
||
1. LLM Microservice | ||
|
||
```bash | ||
http_proxy="" curl http://${host_ip}:9399/v1/lvm -XPOST -d '{"image": "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mP8/5+hnoEIwDiqkL4KAcT9GO0U4BxoAAAAAElFTkSuQmCC", "prompt":"What is this?"}' -H 'Content-Type: application/json' | ||
``` | ||
|
||
2. MegaService | ||
|
||
```bash | ||
curl http://${host_ip}:8888/v1/visualqna -H "Content-Type: application/json" -d '{ | ||
"messages": [ | ||
{ | ||
"role": "user", | ||
"content": [ | ||
{ | ||
"type": "text", | ||
"text": "What'\''s in this image?" | ||
}, | ||
{ | ||
"type": "image_url", | ||
"image_url": { | ||
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"max_tokens": 300 | ||
}' | ||
``` | ||
|
||
## 🚀 Launch the UI | ||
|
||
To access the frontend, open the following URL in your browser: http://{host_ip}:5173. By default, the UI runs on port 5173 internally. If you prefer to use a different host port to access the frontend, you can modify the port mapping in the `compose.yaml` file as shown below: | ||
|
||
```yaml | ||
visualqna-gaudi-ui-server: | ||
image: opea/visualqna-ui:latest | ||
... | ||
ports: | ||
- "80:5173" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
version: "3.8" | ||
|
||
services: | ||
llava-tgi-service: | ||
image: opea/llava-tgi:latest | ||
container_name: tgi-llava-gaudi-server | ||
ports: | ||
- "8399:80" | ||
volumes: | ||
- "./data:/data" | ||
environment: | ||
no_proxy: ${no_proxy} | ||
http_proxy: ${http_proxy} | ||
https_proxy: ${https_proxy} | ||
HF_HUB_DISABLE_PROGRESS_BARS: 1 | ||
HF_HUB_ENABLE_HF_TRANSFER: 0 | ||
HABANA_VISIBLE_DEVICES: all | ||
OMPI_MCA_btl_vader_single_copy_mechanism: none | ||
runtime: habana | ||
cap_add: | ||
- SYS_NICE | ||
ipc: host | ||
command: --model-id ${LVM_MODEL_ID} --max-input-length 4096 --max-total-tokens 8192 | ||
lvm-tgi: | ||
image: opea/lvm-tgi:latest | ||
container_name: lvm-tgi-gaudi-server | ||
depends_on: | ||
- llava-tgi-service | ||
ports: | ||
- "9399:9399" | ||
ipc: host | ||
environment: | ||
no_proxy: ${no_proxy} | ||
http_proxy: ${http_proxy} | ||
https_proxy: ${https_proxy} | ||
LVM_ENDPOINT: ${LVM_ENDPOINT} | ||
HF_HUB_DISABLE_PROGRESS_BARS: 1 | ||
HF_HUB_ENABLE_HF_TRANSFER: 0 | ||
restart: unless-stopped | ||
visualqna-gaudi-backend-server: | ||
image: opea/visualqna:latest | ||
container_name: visualqna-gaudi-backend-server | ||
depends_on: | ||
- llava-tgi-service | ||
- lvm-tgi | ||
ports: | ||
- "8888:8888" | ||
environment: | ||
- no_proxy=${no_proxy} | ||
- https_proxy=${https_proxy} | ||
- http_proxy=${http_proxy} | ||
- MEGA_SERVICE_HOST_IP=${MEGA_SERVICE_HOST_IP} | ||
- LVM_SERVICE_HOST_IP=${LVM_SERVICE_HOST_IP} | ||
ipc: host | ||
restart: always | ||
visualqna-gaudi-ui-server: | ||
image: opea/visualqna-ui:latest | ||
container_name: visualqna-gaudi-ui-server | ||
depends_on: | ||
- visualqna-gaudi-backend-server | ||
ports: | ||
- "5173:5173" | ||
environment: | ||
- no_proxy=${no_proxy} | ||
- https_proxy=${https_proxy} | ||
- http_proxy=${http_proxy} | ||
- CHAT_BASE_URL=${BACKEND_SERVICE_ENDPOINT} | ||
ipc: host | ||
restart: always | ||
|
||
networks: | ||
default: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
export LVM_MODEL_ID="llava-hf/llava-v1.6-mistral-7b-hf" | ||
export LVM_ENDPOINT="http://${host_ip}:8399" | ||
export LVM_SERVICE_PORT=9399 | ||
export MEGA_SERVICE_HOST_IP=${host_ip} | ||
export LVM_SERVICE_HOST_IP=${host_ip} | ||
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:8888/v1/visualqna" |
Oops, something went wrong.