Skip to main content

Vast.ai Provisioning and Monitoring

Hyperscape provides automated tools for provisioning and monitoring GPU instances on Vast.ai for WebGPU streaming deployments.

Overview

Vast.ai is a GPU marketplace that provides affordable NVIDIA GPUs for cloud computing. Hyperscape’s streaming pipeline requires specific GPU configurations to support WebGPU rendering. Key Requirement: Instances MUST have gpu_display_active=true to support WebGPU. This ensures the GPU has display driver support, not just compute access.

Automated Provisioning

Vast.ai Provisioner Script

The provisioner script (./scripts/vast-provision.sh) automatically searches for and rents WebGPU-capable instances. Usage:
What it does:
  1. Searches for instances with gpu_display_active=true (REQUIRED for WebGPU)
  2. Filters by reliability (≥95%), GPU RAM (≥20GB), price (≤$2/hr)
  3. Rents the best available instance
  4. Waits for instance to be ready
  5. Outputs SSH connection details and GitHub secret commands
  6. Saves configuration to /tmp/vast-instance-config.env
Requirements:
  • Vast.ai CLI: pip install vastai
  • API key configured: vastai set api-key YOUR_API_KEY

Search Criteria

The provisioner uses the following filters:

Output

After successful provisioning, the script outputs:

Vast.ai Commands

Search for Instances

Search for WebGPU-capable instances without renting:
This displays available instances matching the search criteria.

Check Instance Status

Check the status of your current instance:
Output includes:
  • Instance ID
  • Status (running, stopped, etc.)
  • GPU model and VRAM
  • Disk space
  • Price per hour
  • Uptime

Destroy Instance

Destroy your current instance to stop billing:
Warning: This permanently deletes the instance and all data. Make sure to backup any important data first.

Vast-Keeper Monitoring Service

Run the vast-keeper monitoring service to automatically manage instances:
The keeper service:
  • Monitors instance health
  • Automatically restarts failed instances
  • Sends alerts on critical failures
  • Manages instance lifecycle

Streaming Health Monitoring

Quick Status Check

Check streaming health on a running Vast.ai instance:
This checks:
  • Server health endpoint
  • Streaming API status
  • Duel context (fighting phase)
  • RTMP bridge status and bytes streamed
  • PM2 process status
  • Recent logs
Example Output:

Detailed Diagnostics

For more detailed diagnostics, SSH into the instance and check: GPU Status:
Should show display mode (not just compute):
Note the Disp.A column shows On - this indicates display driver is active. WebGPU Initialization:
Should show successful WebGPU initialization:
PM2 Processes:
Should show all processes running:

Deployment Validation

The deployment script (scripts/deploy-vast.sh) performs extensive validation:

GPU Display Driver Check

Early validation:
If any check fails, deployment aborts with guidance to rent instances with gpu_display_active=true.

WebGPU Pre-Check Tests

The deployment runs 6 WebGPU tests with different Chrome configurations:
  1. Headless Vulkan: --headless=new --use-vulkan --use-angle=vulkan
  2. Headless EGL: --headless=new --use-gl=egl
  3. Xvfb Vulkan: Non-headless Chrome with Xvfb display
  4. Ozone Headless: --ozone-platform=headless
  5. SwiftShader: Software Vulkan fallback
  6. Playwright Xvfb: Playwright-managed browser with Xvfb
The first successful configuration is used for streaming.

Vulkan ICD Verification

Check Vulkan ICD availability:
Expected output:

Display Server Verification

Check X server:
Expected:
  • Socket exists: /tmp/.X11-unix/X99
  • DISPLAY set: :99 or :99.0

Troubleshooting

WebGPU Not Initializing

Symptom: Deployment fails with “WebGPU initialization failed” Causes:
  1. Instance doesn’t have gpu_display_active=true
  2. NVIDIA display driver not installed
  3. Vulkan ICD not configured
  4. X server not running
Solutions:
  1. Use the provisioner (ensures correct instance type):
  2. Verify GPU display driver:
    Should output Enabled or Enabled, Validated
  3. Check Vulkan ICD:
    Should show NVIDIA ICD loading successfully
  4. Verify X server:

Browser Timeout During Page Load

Symptom: Browser times out (180s limit) when loading game page Cause: Vite dev server JIT compilation is too slow for WebGPU shader compilation Solution: Use production client build:
This serves pre-built client via vite preview instead of dev server, significantly faster page loads.

Stream Disconnects After 30 Minutes

Symptom: Twitch/YouTube disconnects stream after 30 minutes of idle content Cause: Streaming platforms disconnect streams that appear “idle” Solution: Enable placeholder frame mode:
This sends minimal JPEG frames during idle periods to keep the stream alive.

Database Connection Errors

Symptom: “too many clients already” errors during crash loops Cause: PostgreSQL connection pool exhaustion Solution: Reduce connection pool size:
Also increase PM2 restart delay in ecosystem.config.cjs:

Environment Variables

Required for Vast.ai Deployment

Optional Configuration

Deployment Workflow

1. Provision Instance

2. Configure GitHub Secrets

Add the output secrets to your GitHub repository:
  • VAST_SSH_HOST
  • VAST_SSH_PORT
  • VAST_SSH_USER
  • VAST_INSTANCE_ID

3. Deploy via GitHub Actions

The .github/workflows/deploy-vast.yml workflow automatically:
  1. Connects to the instance via SSH
  2. Pulls latest code from main branch
  3. Runs deployment script (scripts/deploy-vast.sh)
  4. Validates WebGPU initialization
  5. Starts PM2 processes
  6. Verifies streaming health

4. Monitor Deployment

Check streaming health:
Or SSH into the instance:

5. Graceful Restart (Zero-Downtime Updates)

Request a restart after the current duel ends:
The server waits for the duel RESOLUTION phase before restarting, ensuring no interruption to active duels or streams.

Cost Optimization

Instance Selection

The provisioner automatically selects the cheapest instance that meets requirements: Typical costs (as of March 2026):
  • RTX 3090 (24GB): $0.30-0.50/hr
  • RTX 4090 (24GB): $0.50-0.80/hr
  • A6000 (48GB): $0.80-1.20/hr
Cost control:
  • Maximum price: $2/hr (configurable in script)
  • Automatic selection of cheapest qualifying instance
  • Destroy instances when not in use

Billing

Vast.ai bills by the hour. To minimize costs:
  1. Destroy instances when not streaming:
  2. Use spot instances (cheaper but can be interrupted)
  3. Monitor usage with bun run vast:status

Advanced Configuration

Custom Search Criteria

Edit scripts/vast-provision.sh to customize search criteria:

Manual Instance Selection

If you prefer to manually select an instance:
  1. Search for instances:
  2. Rent specific instance:
  3. Get SSH details:
  • AGENTS.md: Vast.ai Deployment Architecture section
  • docs/duel-stack.md: Duel stack deployment guide
  • scripts/deploy-vast.sh: Deployment script source code
  • scripts/check-streaming-status.sh: Health check script

Commit History

Vast.ai provisioner was introduced in commit 8591248d (March 1, 2026):
fix(vast): require gpu_display_active=true for WebGPU streaming WebGPU requires GPU display driver support, not just compute. This was causing deployment failures because Xorg/Xvfb couldn’t start without proper display driver access. Changes:
  • vast-keeper: Add gpu_display_active=true to search query (CRITICAL)
  • vast-keeper: Add CLI commands (provision, status, search, destroy)
  • deploy-vast.yml: Add preflight check for GPU display support
  • deploy-vast.yml: Add force_deploy input to override GPU check
  • vast-provision.sh: Update disk size to 120GB
  • package.json: Add vast:* convenience scripts