Skip to main content

Deploying Jobs

This guide covers how to get a job running on a cloud GPU and the common patterns around it: environment, CI, chaining, exec, and debugging.

Deployment Workflows

Two ways to get your code onto a remote VM.

tip

Use the decorator for fast Python iteration on code you'll change often — no image rebuild between runs. Use build + submit for non-Python workloads or hermetic CI-built images.

Function Decorator (Python SDK)

What it is: The @anycloud.function() decorator uses git-based code sync — your repo is cloned at the current commit on the remote VM. Think of it as COPY . /app in your Dockerfile, but always up to date. Your image holds dependencies (PyTorch, CUDA, etc.); your code comes from git. No rebuild between runs, and function arguments are passed directly — no argparse wiring.

When to use: Python workloads where you iterate on code frequently and want to skip the rebuild loop entirely.

Requirements: Python SDK, code committed and pushed to GitHub, git installed in the image.

Example:

@anycloud.function(image="ghcr.io/acme/base:latest", gpu="h100:all")
def train(learning_rate: float, epochs: int = 100):
# Your code is synced here via git — not baked into the image
...

job = train.submit(0.001, epochs=50)

See Python SDK — Function Decorator for the full API.

Build + Submit (CLI, Python SDK)

What it is: The standard Docker workflow — your code is baked into the image via COPY in a Dockerfile, pushed to a registry, then submitted. The running container is a hermetic artifact pinned to a specific image digest, so the same build is reproducible across runs.

When to use: Non-Python workloads or CI/CD pipelines where one image is deployed many times.

Requirements: A pullable image reference. Public registries work without auth; for private images, use GHCR — anycloud login authenticates via GitHub OAuth and anycloud uses the token to pull on the VM.

Examples:

# CLI
anycloud build # builds & pushes to GHCR
anycloud submit ghcr.io/you/repo:latest --gpu-type h100
# Python
client.submit("ghcr.io/you/repo:latest", gpu="h100")

How They Relate

The decorator is built on top of submit. Under the hood, @anycloud.function() calls Client.submit() with your image plus a bootstrap script that clones your repo. The image builder (anycloud.Image / anycloud build) is a convenience for creating the Docker images that either workflow consumes.


Resource Limits & GPUs

Environment & CI

Environment Variables

# Single variable
anycloud submit my-image -e API_KEY=secret123

# Read from current shell
anycloud submit my-image -e API_KEY

# From .env file
anycloud submit my-image --env-file .env

# Combine (flags take precedence over file)
anycloud submit my-image --env-file .env -e API_KEY=override

CI Pipeline

Every CLI command is flag- and env-driven — there are no prompts to navigate. In CI, pass the GitHub token and credentials name via env vars and the rest as flags:

GITHUB_TOKEN=ghp_... ANYCLOUD_CREDENTIALS_NAME=my-aws \
anycloud submit ghcr.io/user/my-app:latest \
--gpu-type h100 \
--spot
Env VarDescription
GITHUB_TOKENGitHub token for auth (alias: ANYCLOUD_TOKEN)
ANYCLOUD_CREDENTIALS_NAMENamed credentials to use (alternative to --credentials)
ANYCLOUD_CONFIGDeployment profile name (alternative to -c, --config)

Chaining Jobs

Chain jobs by waiting for each step before submitting the next:

prep = ac.submit("prep:latest")
prep.wait()

train = ac.submit("train:latest", gpu="h100:8")
train.wait()

eval_job = ac.submit("eval:latest")
eval_job.wait()

For parallel fan-out / fan-in, see Python SDK — JobGroup. To pass data between jobs via buckets (including fan-in to a shared output bucket and cross-cloud storage), see Bucket Sync.

Running Commands

Run commands inside a container or on the VM:

job = ac.submit("train:latest", gpu="h100:8", persist=True)
job.wait()

print(job.exec("nvidia-smi")) # inside the container
print(job.exec("df -h", vm=True)) # on the VM host

See Python SDK — Job Methods and CLI — anycloud exec.

Debugging a Failed Job

Keep the VM running after the job completes with --persist, then SSH in to inspect:

anycloud submit my-image --credentials my-aws --persist
anycloud ssh <deployment-id>
anycloud logs <deployment-id>