Docs - Instance Setup

Virtual Machines

Vast.ai now offers full virtual machines (VMs) in addition to Docker-based instance rentals.

Feature Comparison #

VMs offer the following features not available in Docker:

  • Support for init managers (e.g., systemd). This is necessary for running Docker, Kubernetes, Snap, or other containerization-based applications within an instance.
  • Support for process tracing (ptrace).

VMs have the following drawbacks compared to Docker-based instances:

  • Slower creation and boot times
  • Higher disk overhead
  • Smaller selection of machines
  • Lesser availability of preconfigured templates
  • Only SSH launch mode currently supported

Creating a VM #

First, make sure that you have added your SSH keys to your account page first (see ssh guide), as SSH keys cannot be edited on running VMs. SSH access is currently the only method preconfigured on VM instances.

Use one of the below templates; the template will automatically filter for machines that support VMs and will launch a VM when you rent with that template:

Image (Recommended Template Link) Available Launch Modes Description Provides Use cases Notes
docker.io/vastai/kvm:ubuntu_terminal (link)direct_sshA Ubuntu 22.04 server VM. CUDA, Docker Serving Docker Compose applications; CUDA performance profilingWill refuse to start without SSH pubkeys set; SSH pubkeys will not be able to be changed while instance is running. Env variables will be written to /etc/environment and may need to be sourced by onstart. Onstart script will need interpreter specified via shebangs.

VM Template Customization #

VM images are packaged in docker images from the docker.io/vastai/kvm repository. VM templates must use one of these docker images.

Add vms_enabled=true to the Extra Filters field of the template to filter for machines that support VMs.

VM images must be specified using the fully qualified server/organization/repo:tag name.

Docker options #

VM templates support the following flags in the "Docker options" field. These will have the same effect as in docker-based instances.

  • environment variables: "-e JUPYTER_DIR=/ -e TEST=OK"
    • Environment variables will be written to /etc/environment. To use these environment variables in a script, run source /etc/environment in the beginning.
  • ports: "-p 8081:8081 -p 8082:8082/udp -p 70000:70000"

For more details on these options, see environment.

Launch modes #

Currently only SSH is supported.

On start script #

The On-start script field allows specifying a script to run on instance start. Unlike in docker-based instances, the interpreter must be specified by a shebang (e.g. #!/bin/bash for bash.)

Other differences from Docker-based instances #

  • Currently, the cloud copy utility for VMs only allows migrating the entire VM, instead of allowing individual folders to be copied.
  • Copy is only supported between two VMs, not between VMs and external cloud storage providers.
  • The copy utility for VMs is invoked by vastai vm copy $SRC $DEST.