CLI that compiles and runs CUDA C programs on Modal GPUs
Project description
mcc
mcc is a tiny CLI that compiles and runs a local CUDA C (.cu) program on a cloud GPU using Modal. Install the package published as modal-cuda, keep using the mcc command, and the tool will ship your source to a disposable container, invoke nvcc inside the GPU runtime you pick, stream stdout/stderr back to your terminal, and clean up the artifacts once the run finishes.
Highlights
- Runs CUDA samples on-demand without managing local GPU drivers.
- Lets you choose GPU tier (
T4,A100,H100, etc.) and container image per run. - Accepts extra
nvccarguments for fine-grained builds. - Wraps the entire workflow (upload -> compile -> execute -> teardown) in a single command.
Requirements
- Python 3.12+
- A Modal account with CLI access (
modal token new). - Network access that allows Modal to pull the chosen CUDA container image.
Installation
# install from PyPI
uv add modal-cuda # exposes the `mcc` command
# from source (editable)
uv sync && uv pip install -e .
# run command using uvx
uvx --from modal-cuda mcc ...
Usage
mcc path/to/program.cu [--gpu GPU] [--image IMAGE] [--timeout SECONDS] [--nvcc-arg FLAG ...]
| Flag | Description |
|---|---|
input |
Path to a .cu file. The file must exist and be non-empty. |
--app |
Name of the Modal app; defaults to the source filename. Useful to group runs in the Modal dashboard. |
--gpu |
GPU type to request (T4, L4, A10, A100, A100-40GB, A100-80GB, L40S, H100, H200, B200). Defaults to T4. |
--image |
Container image reference passed to modal.Image.from_registry. Defaults to nvidia/cuda:12.4.1-devel-ubuntu22.04. |
--timeout |
Execution timeout (seconds) enforced by Modal. Defaults to 600. |
--nvcc-arg |
Additional flag forwarded to nvcc. Repeat for multiple flags (e.g., --nvcc-arg -arch=sm_90). |
Example session:
# Run the provided sample kernel on an A100 GPU with verbose PTX output
mcc sample.cu --gpu A100 --nvcc-arg=-Xptxas --nvcc-arg=-v
Modal streams stdout/stderr as the compiler and executable run. If either command exits non‑zero, mcc surfaces the failure message and returns a non-zero status to your shell.
Development
- Install dependencies with
uv sync. - Run
python -m mcc.main path/to/file.cuto skip the console entry point while iterating. - Use
uv run python -m pip install -e .to get an editable install for local testing.
Troubleshooting
modal.ClientException: Unauthorized-> Runmodal token newand try again.nvcc failed to compile...-> Fix compiler errors shown in the streamed stderr or adjust--nvcc-argflags.- Long image pull times -> Prefer the default CUDA image or build a custom Modal image that layers your dependencies once and reuse it via
--image.
License
MIT © ExpressGradient
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file modal_cuda-0.1.1.tar.gz.
File metadata
- Download URL: modal_cuda-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce0993501d61e1fee120fc00f7de0b02e15d6338c51fb50df19ff5a78d8c48be
|
|
| MD5 |
820d8010c478642ee31a557aa4f11d23
|
|
| BLAKE2b-256 |
37ca186abcb422a4883e0b560371a1f74e769835cc7d195bf9155c5fe676735d
|
File details
Details for the file modal_cuda-0.1.1-py3-none-any.whl.
File metadata
- Download URL: modal_cuda-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9f527d3b6fb5ec4d1f555152c6ddfdc261535d69da537f6491c4aca27ed24ee
|
|
| MD5 |
3763bb47ce3ff669957055b902252c86
|
|
| BLAKE2b-256 |
279186b36440e9af3403194ef1f044e12d8386624cefe4f2fb6fab365509139c
|