A simple and easy-to-use vLLM service management tool that can run multiple large language models simultaneously and provides a unified API interface.
- Multi-model Management: Run multiple different AI models simultaneously
- GPU Resource Allocation: Assign independent GPUs for each model
- Unified API Interface: Access all models through one interface, compatible with OpenAI API
- Security Authentication: Support Token authentication protection
- Real-time Response: Support streaming output
- Complete Monitoring: Provide logging and status monitoring
vllm_serve/
├── config.json # Configuration file (model list, ports, GPU, etc.)
├── docker-compose.yml # Docker Compose configuration (auto-generated from config.json)
├── Dockerfile # Docker image configuration
├── docker.py # Docker management tool (generate/start/stop/restart)
├── run_docker.sh # Docker service management script
├── proxy.py # FastAPI proxy service
├── vllmer.py # vLLM process management tool
├── run.sh # Local deployment service management script
├── requirements.txt # Python dependencies
├── log/ # Log directory
│ ├── proxy.log
│ ├── vllm_{model_name}.log
│ └── ...
└── pid/ # Process ID file directory
├── proxy.pid
├── vllm_{model_name}.pid
└── ...
- Python 3.8 or higher
- NVIDIA GPU with CUDA support (for running vLLM)
- Docker and Docker Compose (optional, for containerized deployment)
pip install -r requirements.txtvLLM is a high-performance large language model inference engine. Choose the appropriate installation method based on your CUDA version:
pip install vllm==0.11.0Verify installation:
python -c "import vllm; print(vllm.__version__)"If using Docker to deploy model services, you need to download the vLLM Docker image:
docker pull vllm/vllm:0.11.0Ensure model files are downloaded to the host:
# Example model paths
/models/bge-m3
/models/qwen3Modify the config.json file to configure model paths, ports, GPU, and other parameters.
{
"proxy": {
"token":"your_token",
"listen_port": 20191,
"host": "0.0.0.0"
},
"models": [
{
"enable": true,
"name": "bge-m3",
"path": "/models/bge-m3",
"host": "127.0.0.1",
"port": 8001,
"vllm_env": {
"CUDA_VISIBLE_DEVICES": "1"
},
"vllm_args": [
"--tensor-parallel-size", "1",
"--dtype", "half",
"--task", "embedding",
"--gpu-memory-utilization", "0.3"
]
},
{
"enable": true,
"name": "qwen3",
"path": "/models/qwen3",
"host": "127.0.0.1",
"port": 8002,
"vllm_env": {
"CUDA_VISIBLE_DEVICES": "0"
},
"vllm_args": [
"--tensor-parallel-size", "1",
"--gpu-memory-utilization", "0.8",
"--max-model-len", "32768"
]
}
]
}| Field | Type | Description | Default |
|---|---|---|---|
| token | string | API authentication token, empty means no verification | "" |
| listen_port | int | Proxy service listening port | 8000 |
| host | string | Proxy service listening address | "127.0.0.1" |
| Field | Type | Description | Default |
|---|---|---|---|
| enable | boolean | Whether to enable this model | true |
| name | string | Model name, used when calling API | - |
| path | string | Model file path | - |
| host | string | vLLM service listening address | "127.0.0.1" |
| port | int | vLLM service listening port | - |
| vllm_env | object | Environment variables for vLLM process | {} |
| vllm_args | array | vLLM startup parameters | [] |
The
CUDA_VISIBLE_DEVICESconfiguration item is used to specify the GPU devices visible to the vLLM process. Inconfig.json, each model can be configured with different GPU devices to achieve model parallel computing.
Use the run.sh script to manage local vLLM services and start the proxy service simultaneously.
# Start all services
./run.sh start
# Stop all services
./run.sh stop
# Restart all services
./run.sh restart
# Check service status
./run.sh status
# Operate proxy separately
./run.sh start proxy
./run.sh stop proxy
./run.sh restart proxy
# Operate vLLM services separately
./run.sh start vllm
./run.sh stop vllm
./run.sh restart vllm- Proxy logs:
log/proxy.log - vLLM model logs:
log/vllm_{model_name}.log
- Proxy service:
http://localhost:20191/v1/chat/completions - Model services: Each model has an independent port, such as
http://localhost:8001/v1/chat/completions
This project uses Docker Compose to deploy model services with a hybrid architecture:
- Proxy service: Runs locally (managed by run.sh), responsible for request routing
- Model containers: Each model in an independent container, running with vllm/vllm-openai image
┌─────────────┐
│ Proxy │ (Local process, port 20191)
│ (Local) │
└──────┬──────┘
│
├──────────────┐
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Model 1 │ │ Model 2 │
│ Container │ │ Container │
│ (Port 8001) │ │ (Port 8002) │
└─────────────┘ └─────────────┘
Use the run_docker.sh script to manage Docker model containers and local Proxy service:
./run_docker.sh generate # Generate docker-compose.yml
./run_docker.sh start # Start model containers and local Proxy
./run_docker.sh stop # Stop model containers and local Proxy
./run_docker.sh restart # Restart model containers and local Proxy
./run_docker.sh status # Check all service status
./run_docker.sh logs # View all model container logs
./run_docker.sh logs model-bge-small-zh-v1.5 # View specific model logsThis script will:
- Read
config.jsonconfiguration - Generate independent container services for each enabled model
- Automatically configure GPU allocation and port mapping
- Generate complete docker-compose.yml file
- Automatically start local Proxy service after starting model containers
- Provide unified service management commands
Note: After modifying config.json, you need to run ./run_docker.sh generate to update docker-compose.yml.
./run_docker.sh generate./run_docker.sh start./run_docker.sh status# View all model container logs
./run_docker.sh logs
# View specific model logs
./run_docker.sh logs model-bge-small-zh-v1.5
./run_docker.sh logs model-rsguard-v1
# View Proxy logs (local process)
tail -f log/proxy.log./run_docker.sh stop./run_docker.sh restart./run_docker.sh generate- NVIDIA Container Toolkit: Ensure the host has NVIDIA Container Toolkit installed
- Model paths: Model files need to be correctly mounted into the container
- GPU allocation: Different models are recommended to use different GPUs to avoid resource conflicts
- Network configuration: All model containers are in the same network, Proxy accesses through host ports
- Configuration synchronization: Configuration in docker-compose.yml needs to be consistent with config.json
- Port mapping: Ensure host ports are not occupied
- Log viewing: Use
./run_docker.sh logsto view model container logs, usetail -f log/proxy.logto view Proxy logs - Resource limits: GPU and memory limits can be configured in deploy.resources
- Proxy service: Proxy service runs locally, managed by
./run.sh - Model paths: Model files need to be correctly mounted into the container, path configuration in
config.jsoncannot contain spaces or special characters
The proxy service provides an OpenAI-compatible API interface, and all requests need to include the Authorization header.
curl http://127.0.0.1:20191/healthcurl -X POST http://127.0.0.1:20191/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_token" \
-d '{
"model": "rsguard:v1",
"messages": [
{"role": "user", "content": "Hello!"}
],
"stream": true
}'curl -X POST http://127.0.0.1:20191/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_token" \
-d '{
"model": "rsguard:v1",
"prompt": "How is the weather today?",
"max_tokens": 100
}'curl -X POST http://127.0.0.1:20191/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_token" \
-d '{
"model": "bge-small-zh-v1.5",
"input": "This is a text that needs to be embedded"
}'import requests
url = "http://127.0.0.1:20191/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer your_token"
}
data = {
"model": "rsguard:v1",
"messages": [
{"role": "user", "content": "Hello!"}
]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())- Proxy logs (local):
tail -f log/proxy.log - Model container logs:
./run_docker.sh logs - Specific model logs:
./run_docker.sh logs model-name
- Proxy logs:
tail -f log/proxy.log - vLLM model logs:
tail -f log/vllm_{model_name}.log
- Check if Docker is running normally:
docker ps - Check if model path is correct
- Check if GPU is available:
nvidia-smi - View container logs:
./run_docker.sh logs model-name - Check if port is occupied:
lsof -i :{port}
- Check if model container is running:
./run_docker.sh status - Check model service host and port configuration (host should be 127.0.0.1)
- View Proxy logs:
tail -f log/proxy.log
- Check if model path is correct
- Check if GPU is available:
nvidia-smi - View model logs:
tail -f log/vllm_{model_name}.log - Check if port is occupied:
lsof -i :{port}
- Check if model is running:
python3 vllmer.py status - Check model service host and port configuration
- View proxy logs:
tail -f log/proxy.log
- Check if Authorization header format in request is correct
- Confirm token configuration in config.json
- Ensure Docker and Docker Compose are correctly installed
- Ensure NVIDIA Container Toolkit is installed
- Model paths must exist and be accessible
- Different models are recommended to use different GPUs (configured via vllm_env)
- Proxy service runs locally, managed by
./run.sh - Regularly clean up old files in log and pid directories
- Ensure vLLM is correctly installed and available
- Model paths must exist and be accessible
- Different models are recommended to use different GPUs (configured via vllm_env)
- Stopping services will stop all processes with PID files, including disabled models
- Regularly clean up old files in log and pid directories
This project is licensed under the Apache 2.0 License.