Skip to main content
Launch the top instance from search offers matching the given criteria.

Signature

VastAI.launch_instance(
    gpu_name: str,
    num_gpus: str,
    image: str,
    region: Optional[str] = None,
    disk: Optional[float] = 16.0,
    limit: Optional[int] = 3,
    order: Optional[str] = 'score-',
    login: Optional[str] = None,
    label: Optional[str] = None,
    onstart: Optional[str] = None,
    onstart_cmd: Optional[str] = None,
    entrypoint: Optional[str] = None,
    ssh: bool = False,
    jupyter: bool = False,
    direct: bool = False,
    jupyter_dir: Optional[str] = None,
    jupyter_lab: bool = False,
    lang_utf8: bool = False,
    python_utf8: bool = False,
    env: Optional[str] = None,
    args: Optional[str] = None,
    cancel_unavail: bool = False,
    template_hash: Optional[str] = None
) -> dict

Parameters

gpu_name
str
required
Name of the GPU model, replace spaces with underscores
num_gpus
str
required
Number of GPUs required
image
str
required
Name of the image to use for instance
region
Optional[str]
Geographical location of the instance
disk
Optional[float]
default:"16.0"
Disk space required in GB
limit
Optional[int]
default:"3"
order
Optional[str]
default:"score-"
Comma-separated list of fields to sort on. postfix field with - to sort desc. ex: -o ‘num_gpus,total_flops-’. default=‘score-’
login
Optional[str]
docker login arguments for private repo authentication, surround with ”
label
Optional[str]
label to set on the instance
onstart
Optional[str]
filename to use as onstart script
onstart_cmd
Optional[str]
contents of onstart script as single argument
entrypoint
Optional[str]
override entrypoint for args launch instance
ssh
bool
Launch as an ssh instance type
jupyter
bool
Launch as a jupyter instance instead of an ssh instance
direct
bool
Use (faster) direct connections for jupyter & ssh
jupyter_dir
Optional[str]
For runtype ‘jupyter’, directory in instance to use to launch jupyter. Defaults to image’s working directory
jupyter_lab
bool
For runtype ‘jupyter’, Launch instance with jupyter lab
lang_utf8
bool
Workaround for images with locale problems: install and generate locales before instance launch, and set locale to C.UTF-8
python_utf8
bool
Workaround for images with locale problems: set python’s locale to C.UTF-8
env
Optional[str]
env variables and port mapping options, surround with ”
args
Optional[str]
list of arguments passed to container ENTRYPOINT. Onstart is recommended for this purpose. (must be last argument)
cancel_unavail
bool
Return error if scheduling fails (rather than creating a stopped instance)
template_hash
Optional[str]
template hash which contains all relevant information about an instance. This can be used as a replacement for other parameters describing the instance configuration

Returns

dict

Example

from vastai import VastAI

client = VastAI(api_key="YOUR_API_KEY")
result = client.launch_instance(gpu_name="value", num_gpus="value", image="value")
print(result)