Environment variables¶
.dstack.yml¶
The following read-only environment variables are automatically propagated to configurations for dev environments, tasks, and services:
-
DSTACK_RUN_NAME
– The name of the run.The example below simply prints
vscode
to the output.type: task name: vscode commands: - echo $DSTACK_RUN_NAME
If
name
is not set in the configuration, it is assigned a random name (e.g.wet-mangust-1
). -
DSTACK_REPO_ID
– The ID of the repo. -
DSTACK_GPUS_NUM
– The total number of GPUs in the run.Example:
type: service name: llama31 env: - HF_TOKEN commands: - pip install vllm - vllm serve meta-llama/Meta-Llama-3.1-8B-Instruct --max-model-len 4096 --tensor-parallel-size $DSTACK_GPUS_NUM port: 8000 model: meta-llama/Meta-Llama-3.1-8B-Instruct resources: gpu: 24GB
-
DSTACK_NODES_NUM
– The number of nodes in the run DSTACK_GPUS_PER_NODE
– The number of GPUs per nodeDSTACK_NODE_RANK
– The rank of the node-
DSTACK_NODE_RANK
– The internal IP address the master node.Below is an example of using
DSTACK_NODES_NUM
,DSTACK_GPUS_PER_NODE
,DSTACK_NODE_RANK
, andDSTACK_NODE_RANK
for distributed training:type: task name: train-distrib # The number of instances in the cluster nodes: 2 python: "3.10" commands: - pip install -r requirements.txt - torchrun --nproc_per_node=$DSTACK_GPUS_PER_NODE --node_rank=$DSTACK_NODE_RANK --nnodes=$DSTACK_NODES_NUM --master_addr=$DSTACK_MASTER_NODE_IP --master_port=8008 resnet_ddp.py --num_epochs 20 resources: gpu: 24GB
-
DSTACK_NODES_IPS
– The list of internal IP addresses of all nodes delimited by"\n"
.
Server¶
The following environment variables are supported by the dstack
server and can be specified whether the server is run
via dstack server
or deployed using Docker.
For more details on the options below, refer to the server deployment guide.
-
DSTACK_SERVER_LOG_LEVEL
– Has the same effect as--log-level
. Defaults toINFO
.Example:
$ DSTACK_SERVER_LOG_LEVEL=debug dstack server
-
DSTACK_SERVER_LOG_FORMAT
– Sets format of log output. Can berich
,standard
,json
. Defaults torich
. DSTACK_SERVER_HOST
– Has the same effect as--host
. Defaults to127.0.0.1
.DSTACK_SERVER_PORT
– Has the same effect as--port
. Defaults to3000
.DSTACK_SERVER_ADMIN_TOKEN
– Has the same effect as--token
. Defaults toNone
.DSTACK_SERVER_DIR
– Sets path to store data and server configs. Defaults to~/.dstack/server
.DSTACK_DATABASE_URL
– The database URL to use instead of default SQLite. Currentlydstack
supports Postgres. Example:postgresql+asyncpg://myuser:mypassword@localhost:5432/mydatabase
. Defaults toNone
.DSTACK_SERVER_CLOUDWATCH_LOG_GROUP
– The CloudWatch Logs group for workloads logs. If not set, the default file-based log storage is used.DSTACK_SERVER_CLOUDWATCH_LOG_REGION
– The CloudWatch Logs region. Defaults toNone
.DSTACK_DEFAULT_SERVICE_CLIENT_MAX_BODY_SIZE
– Request body size limit for services, in bytes. Defaults to 64 MiB.DSTACK_FORBID_SERVICES_WITHOUT_GATEWAY
– Forbids registering new services without a gateway if set to any value.
Internal environment variables
The following environment variables are intended for development purposes:
DSTACK_SERVER_ROOT_LOG_LEVEL
– Sets root logger log level. Defaults toERROR
.DSTACK_SERVER_UVICORN_LOG_LEVEL
– Sets uvicorn logger log level. Defaults toERROR
.DSTACK_RUNNER_VERSION
– Sets exact runner version for debug. Defaults tolatest
. Ignored ifDSTACK_RUNNER_DOWNLOAD_URL
is set.DSTACK_RUNNER_DOWNLOAD_URL
– Overridesdstack-runner
binary download URL.DSTACK_SHIM_DOWNLOAD_URL
– Overridesdstack-shim
binary download URL.DSTACK_DEFAULT_CREDS_DISABLED
– Disables default credentials detection if set. Defaults toNone
.DSTACK_LOCAL_BACKEND_ENABLED
– Enables local backend for debug if set. Defaults toNone
.
CLI¶
The following environment variables are supported by the CLI.
DSTACK_CLI_LOG_LEVEL
– Configures CLI logging level. Defaults toINFO
.
Example:
$ DSTACK_CLI_LOG_LEVEL=debug dstack apply -f .dstack.yml
DSTACK_PROJECT
– Has the same effect as--project
. Defaults toNone
.