Skip to main content
Launches the top instance from the search offers based on the given parameters.

Signature

VastAI.launch_instance(
    gpu_name: str,
    num_gpus: str,
    image: str,
    region: str = None,
    disk: float = 16.0,
    limit: int = 3,
    order: str = "score-",
    login: str = None,
    label: str = None,
    onstart: str = None,
    onstart_cmd: str = None,
    entrypoint: str = None,
    ssh: bool = False,
    jupyter: bool = False,
    direct: bool = False,
    jupyter_dir: str = None,
    jupyter_lab: bool = False,
    lang_utf8: bool = False,
    python_utf8: bool = False,
    extra: str = None,
    env: str = None,
    args: list = None,
    force: bool = False,
    cancel_unavail: bool = False,
    template_hash: str = None,
    explain: bool = False,
    raw: bool = False
) -> str

Parameters

gpu_name
str
required
gpu_name
num_gpus
str
required
num_gpus
image
str
required
image
region
str
region
disk
float
default:"16.0"
disk
limit
int
default:"3"
limit
order
str
default:"\"score-\""
order
login
str
login
label
str
label
onstart
str
onstart
onstart_cmd
str
onstart_cmd
entrypoint
str
entrypoint
ssh
bool
default:"False"
ssh
jupyter
bool
default:"False"
jupyter
direct
bool
default:"False"
direct
jupyter_dir
str
jupyter_dir
jupyter_lab
bool
default:"False"
jupyter_lab
lang_utf8
bool
default:"False"
lang_utf8
python_utf8
bool
default:"False"
python_utf8
extra
str
extra
env
str
env
args
list
args
force
bool
default:"False"
force
cancel_unavail
bool
default:"False"
cancel_unavail
template_hash
str
template_hash
explain
bool
default:"False"
explain
raw
bool
default:"False"
raw

Returns

str — Result from the API call.

Example

from vastai import VastAI

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