|
| 1 | +# Build Mega Service of VisualQnA on AMD ROCm |
| 2 | + |
| 3 | +This document outlines the deployment process for a VisualQnA application utilizing the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline on Intel Xeon 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 soon, it will simplify the deployment process for this service. |
| 4 | + |
| 5 | +## 🚀 Build Docker Images |
| 6 | + |
| 7 | +First of all, you need to build Docker Images locally and install the python package of it. |
| 8 | + |
| 9 | +### 1. Build LVM and NGINX Docker Images |
| 10 | + |
| 11 | +```bash |
| 12 | +git clone https://github.com/opea-project/GenAIComps.git |
| 13 | +cd GenAIComps |
| 14 | +docker build --no-cache -t opea/lvm-tgi:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/lvms/tgi-llava/Dockerfile . |
| 15 | +docker build --no-cache -t opea/nginx:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/nginx/Dockerfile . |
| 16 | +``` |
| 17 | + |
| 18 | +### 2. Build MegaService Docker Image |
| 19 | + |
| 20 | +To construct the Mega Service, we utilize the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline within the `visualqna.py` Python script. Build MegaService Docker image via below command: |
| 21 | + |
| 22 | +```bash |
| 23 | +git clone https://github.com/opea-project/GenAIExamples.git |
| 24 | +cd GenAIExamples/VisualQnA |
| 25 | +docker build --no-cache -t opea/visualqna:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile . |
| 26 | +``` |
| 27 | + |
| 28 | +### 3. Build UI Docker Image |
| 29 | + |
| 30 | +Build frontend Docker image via below command: |
| 31 | + |
| 32 | +```bash |
| 33 | +cd GenAIExamples/VisualQnA/ui |
| 34 | +docker build --no-cache -t opea/visualqna-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f docker/Dockerfile . |
| 35 | +``` |
| 36 | + |
| 37 | +### 4. Pull TGI AMD ROCm Image |
| 38 | + |
| 39 | +```bash |
| 40 | +docker pull ghcr.io/huggingface/text-generation-inference:2.4.1-rocm |
| 41 | +``` |
| 42 | + |
| 43 | +Then run the command `docker images`, you will have the following 5 Docker Images: |
| 44 | + |
| 45 | +1. `ghcr.io/huggingface/text-generation-inference:2.4.1-rocm` |
| 46 | +2. `opea/lvm-tgi:latest` |
| 47 | +3. `opea/visualqna:latest` |
| 48 | +4. `opea/visualqna-ui:latest` |
| 49 | +5. `opea/nginx` |
| 50 | + |
| 51 | +## 🚀 Start Microservices |
| 52 | + |
| 53 | +### Setup Environment Variables |
| 54 | + |
| 55 | +Since the `compose.yaml` will consume some environment variables, you need to setup them in advance as below. |
| 56 | + |
| 57 | +**Export the value of the public IP address of your ROCM server to the `host_ip` environment variable** |
| 58 | + |
| 59 | +> Change the External_Public_IP below with the actual IPV4 value |
| 60 | +
|
| 61 | +``` |
| 62 | +export host_ip="External_Public_IP" |
| 63 | +``` |
| 64 | + |
| 65 | +**Append the value of the public IP address to the no_proxy list** |
| 66 | + |
| 67 | +``` |
| 68 | +export your_no_proxy="${your_no_proxy},${host_ip}" |
| 69 | +``` |
| 70 | + |
| 71 | +```bash |
| 72 | +export HOST_IP=${your_host_ip} |
| 73 | +export VISUALQNA_TGI_SERVICE_PORT="8399" |
| 74 | +export VISUALQNA_HUGGINGFACEHUB_API_TOKEN={your_hugginface_api_token} |
| 75 | +export VISUALQNA_CARD_ID="card1" |
| 76 | +export VISUALQNA_RENDER_ID="renderD136" |
| 77 | +export LVM_MODEL_ID="Xkev/Llama-3.2V-11B-cot" |
| 78 | +export MODEL="llava-hf/llava-v1.6-mistral-7b-hf" |
| 79 | +export LVM_ENDPOINT="http://${HOST_IP}:8399" |
| 80 | +export LVM_SERVICE_PORT=9399 |
| 81 | +export MEGA_SERVICE_HOST_IP=${HOST_IP} |
| 82 | +export LVM_SERVICE_HOST_IP=${HOST_IP} |
| 83 | +export BACKEND_SERVICE_ENDPOINT="http://${HOST_IP}:18003/v1/visualqna" |
| 84 | +export FRONTEND_SERVICE_IP=${HOST_IP} |
| 85 | +export FRONTEND_SERVICE_PORT=18001 |
| 86 | +export BACKEND_SERVICE_NAME=visualqna |
| 87 | +export BACKEND_SERVICE_IP=${HOST_IP} |
| 88 | +export BACKEND_SERVICE_PORT=18002 |
| 89 | +export NGINX_PORT=18003 |
| 90 | + |
| 91 | +``` |
| 92 | + |
| 93 | +Note: Please replace with `host_ip` with you external IP address, do not use localhost. |
| 94 | + |
| 95 | +Note: You can use set_env.sh file with bash command (. setset_env.sh) to set up needed variables. |
| 96 | + |
| 97 | +### Start all the services Docker Containers |
| 98 | + |
| 99 | +> Before running the docker compose command, you need to be in the folder that has the docker compose yaml file |
| 100 | +
|
| 101 | +```bash |
| 102 | +cd GenAIExamples/VisualQnA/docker_compose/amd/gpu/rocm |
| 103 | +``` |
| 104 | + |
| 105 | +```bash |
| 106 | +docker compose -f compose.yaml up -d |
| 107 | +``` |
| 108 | + |
| 109 | +### Validate Microservices |
| 110 | + |
| 111 | +Follow the instructions to validate MicroServices. |
| 112 | + |
| 113 | +> Note: If you see an "Internal Server Error" from the `curl` command, wait a few minutes for the microserver to be ready and then try again. |
| 114 | +
|
| 115 | +1. LLM Microservice |
| 116 | + |
| 117 | + ```bash |
| 118 | + 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' |
| 119 | + ``` |
| 120 | + |
| 121 | +2. MegaService |
| 122 | + |
| 123 | +```bash |
| 124 | +curl http://${host_ip}:8888/v1/visualqna -H "Content-Type: application/json" -d '{ |
| 125 | + "messages": [ |
| 126 | + { |
| 127 | + "role": "user", |
| 128 | + "content": [ |
| 129 | + { |
| 130 | + "type": "text", |
| 131 | + "text": "What'\''s in this image?" |
| 132 | + }, |
| 133 | + { |
| 134 | + "type": "image_url", |
| 135 | + "image_url": { |
| 136 | + "url": "https://www.ilankelman.org/stopsigns/australia.jpg" |
| 137 | + } |
| 138 | + } |
| 139 | + ] |
| 140 | + } |
| 141 | + ], |
| 142 | + "max_tokens": 300 |
| 143 | + }' |
| 144 | +``` |
| 145 | + |
| 146 | +## 🚀 Launch the UI |
| 147 | + |
| 148 | +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: |
| 149 | + |
| 150 | +```yaml |
| 151 | + visualqna-gaudi-ui-server: |
| 152 | + image: opea/visualqna-ui:latest |
| 153 | + ... |
| 154 | + ports: |
| 155 | + - "80:5173" |
| 156 | +``` |
0 commit comments