Interactive Runs#

Interactive runs give the ability to debug and iterate quickly inside your cluster in a secure way. Interactivity works on top of the existing MosaicML runs, so before connecting a run workload needs to be submitted to the cluster. For security purposes storage is not persisted, so we recommend utilizing your own cloud storage and git repositories to stream and save data between runs.

Launch an interactive run#

Launching new runs

All runs on reserved clusters can be connected to, regardless of how they were launched. This section goes over mcli interactive, which is a helpful alias for creating simple “sleeper” runs for interactive purposes. You can also create a custom run configuration for interactive purposes through the normal mcli run entrypoint

Launch an interactive run by running:

mcli interactive --max-duration 1 --gpus 1 --tmux --cluster <cluster-name>

This command creates a “sleeper” run that will last for 1 hour (--max-duration 1), request 1 GPU (--gpus 1) and connect to a tmux session (--tmux) within your run. The --max-duration or --hours argument is required to avoid any large, accidental charges from a forgotten run. The --tmux argument is strongly recommended to allow your session to persist through any temporary disconnects. mcli will automatically try to reconnect you to your run whenever you disconnect, so utilizing tmux dramatically improves this experience.

Note that interactive runs act like normal runs:

# see interactive runs on the cluster
mcli util <cluster-name>

# your interactive runs will show up when you call "get runs"
mcli get runs --cluster <cluster-name>

# get more info about your run
mcli describe run <interactive-run-name>

# stop your interactive run early
mcli stop run <interactive-run-name>

# delete it
mcli delete run <interactive-run-name>
from mcli import get_run, get_cluster

# see interactive runs on the cluster
cluster = get_cluster('cluster-name'):
print("Active runs in:",
for run in cluster.utilization.active_runs_by_user:
    print(run.run_name, run.user)

# get your interactive run
run = get_run("interactive-run-name")

# stop your interactive run early

# delete it
Full documentation for the interactive command

Multi-node support

Multi-node interactive runs are currently only supported on reserved, single-tenant clusters

usage: mcli interactive [-h] [--hours [HOURS]] [--name NAME] [--image IMAGE]
                        [--max-duration MAX_DURATION]
                        [--cluster OVERRIDE_CLUSTER]
                        [--gpu-type OVERRIDE_GPU_TYPE]
                        [--gpus OVERRIDE_GPU_NUM]
                        [--instance OVERRIDE_INSTANCE]
                        [--nodes OVERRIDE_NODES]
                        [--node-names OVERRIDE_NODE_NAMES] [--no-connect]
                        [--rank N] [--command COMMAND | --tmux]

Positional Arguments#


Number of hours the interactive session should run

Named Arguments#


Number of hours the interactive session should run


Name for the interactive session. Default: “”interactive””

Default: “interactive”


Docker image to use (default: “mosaicml/pytorch”)

Default: “mosaicml/pytorch”


The maximum time that a run should run for (in hours). If the run exceeds this duration, it will be stopped.

Compute settings#

These settings are used to determine the cluster and compute resources to use for your run

--cluster, --platform

Optional override for MCLI cluster


Optional override for GPU type. Valid GPU type depend on the cluster and GPU number requested


Optional override for number of GPUs. Valid GPU numbers depend on the cluster and GPU type


Optional override for instance type


Optional override for number of nodes. Valid node numbers depend on the cluster and instance type


Optional override for names of nodes to run on (comma-separated if multiple)

Connection settings#

These settings are used for connecting to your interactive session. You can reconnect anytime using mcli connect


Do not connect to the interactive session immediately

Default: True


Connect to the specified node rank within the run

Default: 0


The command to execute in the run. By default you will be dropped into a bash shell


Use tmux as the entrypoint for your run so your session is robust to disconnects

Default: False

Update a run’s max duration#

After creating an interactive run, you can change its maximum duration.

mcli update run <interactive-run-name> --max-duration <hours>

Connect to a run in the terminal#

Regardless of how you launched the run, you can connect to any active run using:

mcli connect <run-name> --tmux

By default, the session will connect inside a bash shell. We highly recommend using tmux as the entrypoint for your run so your session is robust to disconnects (such as a local internet outage). You can also configure a command other than bash or tmux to execute in the run:

mcli connect --command "top"

If you are running multi-node interactive runs, you can specify the zero-indexed node rank via:

mcli connect --rank 2

Connect to a run with VSCode#


Due to VSCode Server licensing, we cannot integrate directly with the native VS code remote development extensions. This guide outlines and documents how to get started with the VSCode server using tunneling

First time local setup: Install VSCode and the remote development extension pack. We recommend reviewing the system requirements and installation guide for the extension pack as some requirements are highly dependent on your operating system.

Step 1: Create an interactive run as documented above

Step 2: Connect to that run via mcli connect

Step 3: Run the following commands to download VS Code server and start it:

trap '/tmp/code tunnel unregister' EXIT
cd /tmp && curl -Lk '' --output vscode_cli.tar.gz
tar -xf vscode_cli.tar.gz
/tmp/code tunnel --accept-server-license-terms --no-sleep --name mml-dev-01

This will output something like:

* Visual Studio Code Server
* By using the software, you agree to
* the Visual Studio Code Server License Terms ( and
* the Microsoft Privacy Statement (
To grant access to the server, please log into and use code ABCD-1234

Step 4: Authenticate using the code provided here and authorize your github account

Authenticate using the code provided

Authorize your github account

Step 5: From an existing VSCode window, connect using remote tunnel by selecting the blue remote window button on the very left of bottom sidebar. Select “Connect to tunnel” from “Remote-Tunnels” and then select the tunnel name (default: “mml-dev-01”)

Alternatively, you can connect in the browser at:

Connect to a run with Jupyter Notebooks, via VSCode#

Follow the steps above to set up an interactive instance via VSCode, then install the Jupyter extension and specify a kernel. Once configured, you should be able to run any .ipynb notebook in your interactive instance via VSCode!