Skip to main content

mcr — Modal CUDA Runner

Run a CUDA .cu file on an NVIDIA GPU from Modal, from anywhere on your machine, in one command. No local GPU required.

Install

pip install git+https://github.com/<your-handle>/modal-cuda-runner
modal setup   # one-time Modal authentication

Usage

$ mcr test.cu
→ Running test.cu on T4
  GPU: Tesla T4
  Vector length: 1048576
  Errors: 0
  Sample: c[0]=3.0 c[1048575]=3.0
✓ Finished executing on Modal (3.42s)

Pick a different GPU with --gpu:

mcr test.cu --gpu H100

Supported: T4 (default), L4, A10G, A100, A100-80GB, H100.

The CUDA program's stdout is forwarded to your stdout and its exit code becomes mcr's exit code, so mcr composes cleanly with shell pipes and CI.

How it works

mcr reads the directory containing your .cu file and sends all of its regular files as a function argument to a Modal function running an nvidia/cuda:12.9.0-devel-ubuntu22.04 image. The directory tree is recreated in a temporary directory in the container, so local headers and other relative-path dependencies are available. Compilation and execution use that temporary directory as their working directory. Symlinks are skipped and never followed outside the source directory.

This is intentionally a simple first implementation: everything beneath the source directory is uploaded on every invocation. Keep source files in a focused directory and avoid placing secrets or large unrelated files beside them. See TODO.md for the planned dependency-aware replacement.

Because the image never changes across invocations, Modal caches it forever — no per-run image rebuild.

On the remote container: nvcc compiles the source, then the resulting binary runs on the requested GPU. stdout streams back as it's produced.

  • First run: slower — container cold start on Modal's side.
  • Subsequent runs: typically a few seconds for small kernels.

Not yet supported

Intentionally scoped small for v1:

  • Passing CLI args or stdin to the CUDA binary
  • Custom nvcc flags

Metadata

Release files for modal-cuda-runner 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modal-cuda-runner 0.1.2
File Size Uploaded Provenance Actions
modal_cuda_runner-0.1.2.tar.gz 6.5 kB Without provenance Details for modal_cuda_runner-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for modal-cuda-runner 0.1.2
File Interpreter ABI Platform Actions
modal_cuda_runner-0.1.2-py3-none-any.whl Python 3 none any Details for modal_cuda_runner-0.1.2-py3-none-any.whl

Total release size: 13.5 kB

Security for modal-cuda-runner 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page