Skip to main content
Create a new instance

Usage

vastai create instance ID [OPTIONS] [--args ...]

Arguments

id
integer
required
id of instance type to launch (returned from search offers)

Options

--template_hash
string
Create instance from template info
--user
string
User to use with docker create. This breaks some images, so only use this if you are certain you need it.
--disk
number
default:"10"
size of local disk partition in GB
--image
string
docker container image to launch
--login
string
docker login arguments for private repo authentication, surround with ”
--label
string
label to set on the instance
--onstart
string
filename to use as onstart script
--onstart-cmd
string
contents of onstart script as single argument
--entrypoint
string
override entrypoint for args launch instance
--ssh
boolean
Launch as an ssh instance type
--jupyter
boolean
Launch as a jupyter instance instead of an ssh instance
--direct
boolean
Use (faster) direct connections for jupyter & ssh
--jupyter-dir
string
For runtype ‘jupyter’, directory in instance to use to launch jupyter. Defaults to image’s working directory
--jupyter-lab
boolean
For runtype ‘jupyter’, Launch instance with jupyter lab
--lang-utf8
boolean
Workaround for images with locale problems: install and generate locales before instance launch, and set locale to C.UTF-8
--python-utf8
boolean
Workaround for images with locale problems: set python’s locale to C.UTF-8
--env
string
env variables and port mapping options, surround with ”
--args
string
list of arguments passed to container ENTRYPOINT. Onstart is recommended for this purpose. (must be last argument)
--force
boolean
Skip sanity checks when creating from an existing instance
--cancel-unavail
boolean
Return error if scheduling fails (rather than creating a stopped instance)
--bid_price
number
(OPTIONAL) create an INTERRUPTIBLE instance with per machine bid price in $/hour
--create-volume
integer
Create a new local volume using an ID returned from the “search volumes” command and link it to the new instance
ID of an existing rented volume to link to the instance during creation. (returned from “show volumes” cmd)
--volume-size
integer
Size of the volume to create in GB. Only usable with —create-volume (default 15GB)
--mount-path
string
The path to the volume from within the new instance container. e.g. /root/volume
--volume-label
string
(optional) A name to give the new volume. Only usable with —create-volume

Description

Performs the same action as pressing the “RENT” button on the website at https://console.vast.ai/create/ Creates an instance from an offer ID (which is returned from “search offers”). Each offer ID can only be used to create one instance. Besides the offer ID, you must pass in an ‘—image’ argument as a minimum. If you use args/entrypoint launch mode, we create a container from your image as is, without attempting to inject ssh and or jupyter. If you use the args launch mode, you can override the entrypoint with —entrypoint, and pass arguments to the entrypoint with —args. If you use —args, that must be the last argument, as any following tokens are consumed into the args string. For ssh/jupyter launch types, use —onstart-cmd to pass in startup script, instead of —entrypoint and —args.

Examples

# create an on-demand instance with the PyTorch (cuDNN Devel) template and 64GB of disk
vastai create instance 384826 --template_hash 661d064bbda1f2a133816b6d55da07c3 --disk 64

# create an on-demand instance with the pytorch/pytorch image, 40GB of disk, open 8081 udp, direct ssh, set hostname to billybob, and a small onstart script
vastai create instance 6995713 --image pytorch/pytorch --disk 40 --env '-p 8081:8081/udp -h billybob' --ssh --direct --onstart-cmd "env | grep _ >> /etc/environment; echo 'starting up'";

# create an on-demand instance with the bobsrepo/pytorch:latest image, 20GB of disk, open 22, 8080, jupyter ssh, and set some env variables
vastai create instance 384827  --image bobsrepo/pytorch:latest --login '-u bob -p 9d8df!fd89ufZ docker.io' --jupyter --direct --env '-e TZ=PDT -e XNAME=XX4 -p 22:22 -p 8080:8080' --disk 20

# create an on-demand instance with the pytorch/pytorch image, 40GB of disk, override the entrypoint to bash and pass bash a simple command to keep the instance running. (args launch without ssh/jupyter)
vastai create instance 5801802 --image pytorch/pytorch --disk 40 --onstart-cmd 'bash' --args -c 'echo hello; sleep infinity;'

# create an interruptible (spot) instance with the PyTorch (cuDNN Devel) template, 64GB of disk, and a bid price of $0.10/hr
vastai create instance 384826 --template_hash 661d064bbda1f2a133816b6d55da07c3 --disk 64 --bid_price 0.1

Return value:
Returns a json reporting the instance ID of the newly created instance:
{'success': True, 'new_contract': 7835610}

Global Options

The following options are available for all commands:
OptionDescription
--url URLServer REST API URL
--retry NRetry limit
--rawOutput machine-readable JSON
--explainVerbose explanation of API calls
--api-key KEYAPI key (defaults to ~/.config/vastai/vast_api_key)