Skip to main content

Run any compute job on AWS with a single command

Project description

crunr

Run any compute job on AWS EC2 with a single command — no DevOps required.

crunr run train.py --gpu

crunr provisions an instance, uploads your code, streams live output, downloads results, and terminates the instance automatically. Zero idle cost.

Install

pip install crunr

Requires Python 3.10+ and an AWS account.

Quick start

# 1. Configure AWS credentials (one-time)
crunr auth

# 2. Run a script on the cheapest CPU instance
crunr run script.py

# 3. Run on a GPU instance
crunr run train.py --gpu

# 4. Specify minimum VRAM
crunr run train.py --gpu --memory 24

# 5. Pass environment variables
crunr run train.py --env EPOCHS=50 --env LR=0.001

How it works

  1. Provision — selects the cheapest matching spot instance, falls back to on-demand
  2. Sync — uploads your local directory to the instance (rsync or scp+tar)
  3. Execute — runs your command with live log streaming
  4. Collect — downloads any outputs/ directory back to your machine
  5. Terminate — instance is always destroyed, even on Ctrl+C or crash

Commands

Command Description
crunr auth Configure AWS credentials
crunr run <script> Run a job on EC2
crunr jobs Show job history
crunr ps List running instances
crunr clean Terminate all orphaned instances

crunr run options

--gpu               Request a GPU instance (cheapest available)
--memory GB         Minimum GPU VRAM or RAM in GB
--instance TYPE     Exact EC2 instance type (e.g. g5.xlarge)
--disk GB           Root EBS volume size (default: 8 GB CPU, 100 GB GPU)
--env KEY=VALUE     Environment variable passed to the job (repeatable)
--dir PATH          Local directory to sync (default: current directory)
--on-demand         Use on-demand pricing instead of spot
--profile NAME      AWS credential profile
--region REGION     Override AWS region

Saving outputs

Your script can write files to an outputs/ directory. crunr automatically downloads it after the job finishes:

import os
os.makedirs("outputs", exist_ok=True)
with open("outputs/result.txt", "w") as f:
    f.write("done")

AWS IAM permissions

The IAM user needs these permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:RunInstances", "ec2:TerminateInstances", "ec2:DescribeInstances",
        "ec2:DescribeImages", "ec2:DescribeSpotPriceHistory",
        "ec2:CreateKeyPair", "ec2:DeleteKeyPair", "ec2:DescribeKeyPairs",
        "ec2:CreateSecurityGroup", "ec2:DescribeSecurityGroups",
        "ec2:AuthorizeSecurityGroupIngress",
        "ec2:CreateTags",
        "sts:GetCallerIdentity"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": "iam:CreateServiceLinkedRole",
      "Resource": "arn:aws:iam::*:role/aws-service-role/spot.amazonaws.com/*"
    }
  ]
}

Cost

You only pay for the time the instance runs. Spot instances are typically 60–90% cheaper than on-demand.

Example costs (spot, us-east-1):

  • t3.micro CPU job — ~$0.003/hr
  • g4dn.xlarge GPU (T4) — ~$0.16/hr
  • g5.xlarge GPU (A10G) — ~$0.34/hr

Data transfer into EC2 is free. Transfer out costs ~$0.09/GB.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crunr-0.1.0.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crunr-0.1.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file crunr-0.1.0.tar.gz.

File metadata

  • Download URL: crunr-0.1.0.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for crunr-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78d4eba6b34ff97d05e821dfa6484f3d0e6e563cf0be3f1c17009bbc05808faa
MD5 d5a63eb8f46e843220d55d8bf8ed4f0f
BLAKE2b-256 6778d871765d3c04ae26436bde34633495e6a67957835de20d91da470c44d3a0

See more details on using hashes here.

File details

Details for the file crunr-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crunr-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for crunr-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ee3d927274859e0ba6af05ca4ab533d43330f06e1e0a383bdc2dad39fa6d7d0
MD5 1c1e45dd41991948f3b178bc150c7b02
BLAKE2b-256 32d100ba8db106bca72ed0dc0f5d13094a26e7cab762177029c47dc88ce967d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page