Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 3.11 KB

README.md

File metadata and controls

76 lines (57 loc) · 3.11 KB

Packer templates for dstack VM images

This directory contains HashiCorp Packer templates for building VM images that are then used by dstack when running instances on some of the VM-based backends. While dstack uses standard OS images for some backends, backends with custom-built images have an advantage because these images are optimized for dstack, e.g. they contain pre-pulled dstack Docker images, which reduces the startup time of dstack jobs.

For most backends, we build two images: one for CPU-only instances, typically published as dstack-X.Y, and one for NVIDIA GPU instances, typically published as dstack-cuda-X.Y, where X.Y is the image version. Some backends may have additional images, e.g. Azure has dstack-grid-X.Y for instances requiring NVIDIA Grid drivers.

The release and staging versions of the images are built automatically using GitHub Actions. If you need to build the images manually, see .github/workflows/docker.yml for examples of how to use the templates. Additional instructions for some backends are provided below.

Azure

Follow installation instruction for Azure CLI az. Login for managing resources:

$ az login

Steps below follows HOWTO. Create group as container for result image. Value packer is from property managed_image_resource_group_name of azure-arm packer's builder. Value eastus is property location of azure-arm (Azure has two kind notation for the same location).

$ az group create -n packer -l eastus

Packer allocates resources on its own. It requires access to subscription. Obtain id.

$ az account show --query "{ subscription_id: id }"
{
  "subscription_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
}

Create credentials for packer.

$ az ad sp create-for-rbac --role Contributor --scopes /subscriptions/<subscription_id> --query "{ client_id: appId, client_secret: password, tenant_id: tenant }"
{
    "client_id": "f5b6a5cf-fbdf-4a9f-b3b8-3c2cd00225a4",
    "client_secret": "0e760437-bf34-4aad-9f8d-870be799c55d",
    "tenant_id": "72f988bf-86f1-41af-91ab-2d7cd011db47"
}

Set environment variables.

Env Azure
AZURE_CLIENT_ID client_id
AZURE_CLIENT_SECRET client_secret
AZURE_TENANT_ID tenant_id
AZURE_SUBSCRIPTION_ID subscription_id

Nebius

Create credentials for packer. The compute.admin role is not sufficient, use admin instead.

ncp config profile create packer
ncp config set service-account-key path/to/service_account.json
ncp config set endpoint api.ai.nebius.cloud:443
export PKR_VAR_nebius_token=$(ncp iam create-token)

Then build the images.

export PKR_VAR_nebius_folder_id=...
export PKR_VAR_nebius_subnet_id=...
# no CUDA
packer build -only yandex.nebius -var image_version=0.4rc3 .
# with CUDA
packer build -only yandex.nebius-cuda -var image_version=0.4rc3 .