Deploying AI Inference Platform with Ubuntu 24.04 and Integrating Chinese Large Language Models: A Practical Guide

    This guide provides step-by-step instructions for deploying an AI inference platform on Ubuntu 24.04 LTS, with special focus on integrating Chinese large language models (LLMs). The tutorial covers system requirements, platform installation, model configuration, security considerations, and performance optimization.

    System Requirements

    Server Specifications

    • Recommended configuration: 8-core CPU, 32GB RAM physical server or cloud instance
    • Operating system: Ubuntu 24.04 LTS (Long Term Support)
    • User management: Create dedicated deployment user (example uses root for demonstration)
      1. # Create dedicated user with sudo privileges
      2. adduser aiadmin
      3. usermod -aG sudo aiadmin
      4. su - aiadmin

    Network Configuration

    • Open SSH port (default 22)
    • Configure firewall rules to restrict external access to specific IPs
    • Ensure public internet access for model API calls (or VPN tunnel)

    AI Inference Platform Deployment

    Node.js Installation

    Use nvm for version management:

    1. # Install nvm
    2. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    3. source ~/.bashrc
    4. # Install Node.js 22 LTS
    5. nvm install 22
    6. nvm alias default 22
    7. # Verify installation
    8. node -v # Should show v22.x.x
    9. npm -v # Should show 10.x.x or higher

    Platform Installation

    Install and verify the inference platform:

    1. npm install -g openclaw@latest
    2. # Verify installation
    3. openclaw --version # Should show version like 2026.3.2

    Troubleshooting:

    • Non-empty directory error:
      1. rm -rf ~/.npm-global/lib/node_modules/openclaw
      2. npm cache clean --force
      3. npm install -g openclaw@latest
    • Permission issues: Use sudo chown -R $USER ~/.npm
    • Network issues: Configure local mirrors for faster installation

    Model Integration Configuration

    Interactive Setup

    Configure model access through wizard:

    1. openclaw config

    Follow these steps:

    1. Select “Add custom provider”
    2. Enter provider name (e.g., zhipu-glm)
    3. Configure API endpoint (example format):
      1. https://[provider-domain]/api/paas/v4/chat/completions
    4. Enter valid API key (pre-applied from provider)

    Configuration File

    Generated config.json structure:

    1. {
    2. "providers": {
    3. "zhipu-glm": {
    4. "api_base": "https://open.bigmodel.cn/api/paas/v4",
    5. "api_key": "sk-xxxxxxxxxxxxxxxx",
    6. "model": "glm-4.7-flash",
    7. "max_tokens": 4096
    8. }
    9. }
    10. }

    Model Verification

    Test configuration with simple inference:

    1. openclaw test --provider zhipu-glm --prompt "Hello"

    Expected response structure:

    1. {
    2. "id": "chatcmpl-xxxx",
    3. "object": "chat.completion",
    4. "choices": [{
    5. "message": {"role": "assistant", "content": "Hello! How can I help you?"}
    6. }]
    7. }

    Secure Access Solutions

    SSH Tunneling

    Secure web interface access from local machine:

    1. # Windows (PowerShell)
    2. ssh -L 3000:localhost:3000 aiadmin@server-ip -N
    3. # macOS/Linux
    4. ssh -N -L 3000:localhost:3000 aiadmin@server-ip

    Access via http://localhost:3000

    Nginx Reverse Proxy (Production)

    Recommended HTTPS configuration:

    1. server {
    2. listen 443 ssl;
    3. server_name ai.example.com;
    4. ssl_certificate /path/to/cert.pem;
    5. ssl_certificate_key /path/to/key.pem;
    6. location / {
    7. proxy_pass http://localhost:3000;
    8. proxy_set_header Host $host;
    9. proxy_set_header X-Real-IP $remote_addr;
    10. }
    11. }

    Performance Optimization

    Resource Allocation

    • Single instance: ≤4 concurrent requests
    • GPU acceleration required for high-memory models

    Caching Configuration

    1. # Enable response caching
    2. openclaw config --set cache.enabled=true
    3. openclaw config --set cache.size=1024MB

    Log Management

    Configure log rotation:

    1. sudo nano /etc/logrotate.d/openclaw

    Add configuration:

    1. /var/log/openclaw/*.log {
    2. daily
    3. rotate 7
    4. compress
    5. missingok
    6. notifempty
    7. }

    Troubleshooting Guide

    Symptom Possible Cause Solution
    502 Bad Gateway Service not running systemctl restart openclaw
    API timeout Network restrictions Check firewall/security group rules
    401 Unauthorized Invalid API key Regenerate key and update config
    GPU memory exhausted Large model size Reduce max_tokens parameter

    Advanced Features

    Multi-Model Routing

    Configure intelligent routing:

    1. {
    2. "routing": {
    3. "default": "zhipu-glm",
    4. "rules": [
    5. {
    6. "pattern": "^/tech/",
    7. "provider": "tech-specialized-model"
    8. }
    9. ]
    10. }
    11. }

    Custom Prompt Templates

    Create template files in templates/ directory:

    1. // templates/customer_service.json
    2. {
    3. "prompt": "As customer service, respond friendly: {query}"
    4. }

    Invoke with template:

    1. openclaw chat --template customer_service --query "How to return items?"

    Maintenance and Upgrades

    Regular Updates

    1. npm update -g openclaw

    Backup Strategy

    1. # Backup configuration and data
    2. tar czvf openclaw_backup_$(date +%Y%m%d).tar.gz /etc/openclaw /var/lib/openclaw

    Monitoring Setup

    1. # Install monitoring tools
    2. sudo apt install prometheus-node-exporter

    This comprehensive guide enables developers to quickly build secure, private AI inference platforms on Ubuntu 24.04. Adjust parameters according to specific business requirements and validate in test environments before production deployment. For enterprise applications, consider containerization and CI/CD pipelines for automated operations.