|
| 1 | +[简体中文](../zh/get_started/quick_start_qwen25_vl.md) |
| 2 | + |
| 3 | +# Deploy Qwen2.5-VL in 10 Minutes |
| 4 | + |
| 5 | +Before deployment, ensure your environment meets the following requirements: |
| 6 | + |
| 7 | +- GPU Driver ≥ 535 |
| 8 | +- CUDA ≥ 12.3 |
| 9 | +- cuDNN ≥ 9.5 |
| 10 | +- Linux X86_64 |
| 11 | +- Python ≥ 3.10 |
| 12 | + |
| 13 | +This guide uses the lightweight Qwen2.5-VL model for demonstration, which can be deployed on most hardware configurations. Docker deployment is recommended. |
| 14 | + |
| 15 | +For more information about how to install FastDeploy, refer to the [installation document](installation/README.md). |
| 16 | + |
| 17 | +## 1. Launch Service |
| 18 | + |
| 19 | +Please download the qwen25-vl model in advance: such as [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct) |
| 20 | + |
| 21 | +Add the following configuration in `config.json` |
| 22 | +```text |
| 23 | + "rope_3d": true, |
| 24 | + "freq_allocation": 16 |
| 25 | +``` |
| 26 | + |
| 27 | +After installing FastDeploy, execute the following command in the terminal to start the service. For the configuration method of the startup command, refer to [Parameter Description](../parameters.md) |
| 28 | + |
| 29 | +``` |
| 30 | +export ENABLE_V1_KVCACHE_SCHEDULER=1 |
| 31 | +python -m fastdeploy.entrypoints.openai.api_server \ |
| 32 | + --model You/Path/Qwen2.5-VL-7B-Instruct \ |
| 33 | + --port 8180 \ |
| 34 | + --metrics-port 8181 \ |
| 35 | + --engine-worker-queue-port 8182 \ |
| 36 | + --max-model-len 32768 \ |
| 37 | + --max-num-seqs 32 |
| 38 | +``` |
| 39 | + |
| 40 | +> 💡 Note: In the path specified by ```--model```, if the subdirectory corresponding to the path does not exist in the current directory, it will try to query whether AIStudio has a preset model based on the specified model name (such as ```Qwen/Qwen2.5-VL-7B-Instruct```). If it exists, it will automatically start downloading. The default download path is: ```~/xx```. For instructions and configuration on automatic model download, see [Model Download](../supported_models.md). |
| 41 | +```--max-model-len``` indicates the maximum number of tokens supported by the currently deployed service. |
| 42 | +```--max-num-seqs``` indicates the maximum number of concurrent processing supported by the currently deployed service. |
| 43 | + |
| 44 | +**Related Documents** |
| 45 | +- [Service Deployment](../online_serving/README.md) |
| 46 | +- [Service Monitoring](../online_serving/metrics.md) |
| 47 | + |
| 48 | +## 2. Request the Service |
| 49 | +After starting the service, the following output indicates successful initialization: |
| 50 | + |
| 51 | +```shell |
| 52 | +api_server.py[line:91] Launching metrics service at http://0.0.0.0:8181/metrics |
| 53 | +api_server.py[line:94] Launching chat completion service at http://0.0.0.0:8180/v1/chat/completions |
| 54 | +api_server.py[line:97] Launching completion service at http://0.0.0.0:8180/v1/completions |
| 55 | +INFO: Started server process [13909] |
| 56 | +INFO: Waiting for application startup. |
| 57 | +INFO: Application startup complete. |
| 58 | +INFO: Uvicorn running on http://0.0.0.0:8180 (Press CTRL+C to quit) |
| 59 | +``` |
| 60 | + |
| 61 | +### Health Check |
| 62 | + |
| 63 | +Verify service status (HTTP 200 indicates success): |
| 64 | + |
| 65 | +```shell |
| 66 | +curl -i http://0.0.0.0:8180/health |
| 67 | +``` |
| 68 | + |
| 69 | +### cURL Request |
| 70 | +Send requests as follows: |
| 71 | + |
| 72 | +```shell |
| 73 | +curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \ |
| 74 | +-H "Content-Type: application/json" \ |
| 75 | +-d '{ |
| 76 | + "messages": [ |
| 77 | + {"role": "user", "content": "Rewrite Li Bai's 'Quiet Night Thoughts' as a modern poem"} |
| 78 | + ] |
| 79 | +}' |
| 80 | +``` |
| 81 | +
|
| 82 | +For image inputs: |
| 83 | +
|
| 84 | +```shell |
| 85 | +curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \ |
| 86 | +-H "Content-Type: application/json" \ |
| 87 | +-d '{ |
| 88 | + "messages": [ |
| 89 | + {"role": "user", "content": [ |
| 90 | + {"type":"image_url", "image_url": {"url":"https://paddlenlp.bj.bcebos.com/datasets/paddlemix/demo_images/example2.jpg"}}, |
| 91 | + {"type":"text", "text":"From which era does the artifact in the image originate?"} |
| 92 | + ]} |
| 93 | + ] |
| 94 | +}' |
| 95 | +``` |
| 96 | +
|
| 97 | +For video inputs: |
| 98 | +
|
| 99 | +```shell |
| 100 | +curl -X POST "http://0.0.0.0:8180/v1/chat/completions" \ |
| 101 | +-H "Content-Type: application/json" \ |
| 102 | +-d '{ |
| 103 | + "messages": [ |
| 104 | + {"role": "user", "content": [ |
| 105 | + {"type":"video_url", "video_url": {"url":"https://bj.bcebos.com/v1/paddlenlp/datasets/paddlemix/demo_video/example_video.mp4"}}, |
| 106 | + {"type":"text", "text":"How many apples are in the scene?"} |
| 107 | + ]} |
| 108 | + ] |
| 109 | +}' |
| 110 | +``` |
| 111 | +
|
| 112 | +### Python Client (OpenAI-compatible API) |
| 113 | +
|
| 114 | +FastDeploy's API is OpenAI-compatible. You can also use Python for streaming requests: |
| 115 | +
|
| 116 | +```python |
| 117 | +import openai |
| 118 | +host = "0.0.0.0" |
| 119 | +port = "8180" |
| 120 | +client = openai.Client(base_url=f"http://{host}:{port}/v1", api_key="null") |
| 121 | +
|
| 122 | +response = client.chat.completions.create( |
| 123 | + model="null", |
| 124 | + messages=[ |
| 125 | + {"role": "user", "content": [ |
| 126 | + {"type": "image_url", "image_url": {"url": "https://paddlenlp.bj.bcebos.com/datasets/paddlemix/demo_images/example2.jpg"}}, |
| 127 | + {"type": "text", "text": "From which era does the artifact in the image originate?"}, |
| 128 | + ]}, |
| 129 | + ], |
| 130 | + stream=True, |
| 131 | +) |
| 132 | +for chunk in response: |
| 133 | + if chunk.choices[0].delta: |
| 134 | + print(chunk.choices[0].delta.content, end='') |
| 135 | +print('\n') |
| 136 | +``` |
0 commit comments