modal-cuda 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ExpressGradient
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: modal-cuda
3
+ Version: 0.1.0
4
+ Summary: CLI that compiles and runs CUDA C programs on Modal GPUs
5
+ Author: ExpressGradient
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 ExpressGradient
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Requires-Python: >=3.12
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: modal>=1.2.2
32
+ Dynamic: license-file
33
+
34
+ ## mcc
35
+
36
+ `mcc` is a tiny CLI that compiles and runs a local CUDA C (`.cu`) program on a cloud GPU using [Modal](https://modal.com). 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.
37
+
38
+ ### Highlights
39
+
40
+ - Runs CUDA samples on-demand without managing local GPU drivers.
41
+ - Lets you choose GPU tier (`T4`, `A100`, `H100`, etc.) and container image per run.
42
+ - Accepts extra `nvcc` arguments for fine-grained builds.
43
+ - Wraps the entire workflow (upload → compile → execute → teardown) in a single command.
44
+
45
+ ## Requirements
46
+
47
+ - Python 3.12+
48
+ - A Modal account with CLI access (`modal token new`).
49
+ - Network access that allows Modal to pull the chosen CUDA container image.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ # install from PyPI/TestPyPI
55
+ pip install modal-cuda # exposes the `mcc` command
56
+
57
+ # from source (editable)
58
+ uv sync && uv pip install -e .
59
+ # or: pip install -e .
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ```bash
65
+ mcc path/to/program.cu [--gpu GPU] [--image IMAGE] [--timeout SECONDS] [--nvcc-arg FLAG ...]
66
+ ```
67
+
68
+ | Flag | Description |
69
+ | --- | --- |
70
+ | `input` | Path to a `.cu` file. The file must exist and be non-empty. |
71
+ | `--app` | Name of the Modal app; defaults to the source filename. Useful to group runs in the Modal dashboard. |
72
+ | `--gpu` | GPU type to request (`T4`, `L4`, `A10`, `A100`, `A100-40GB`, `A100-80GB`, `L40S`, `H100`, `H200`, `B200`). Defaults to `T4`. |
73
+ | `--image` | Container image reference passed to `modal.Image.from_registry`. Defaults to `nvidia/cuda:13.0.2-cudnn-devel-ubuntu22.04`. |
74
+ | `--timeout` | Execution timeout (seconds) enforced by Modal. Defaults to 600. |
75
+ | `--nvcc-arg` | Additional flag forwarded to `nvcc`. Repeat for multiple flags (e.g., `--nvcc-arg -arch=sm_90`). |
76
+
77
+ Example session:
78
+
79
+ ```bash
80
+ # Run the provided sample kernel on an A100 GPU with verbose PTX output
81
+ mcc sample.cu --gpu A100 --nvcc-arg -Xptxas --nvcc-arg -v
82
+ ```
83
+
84
+ 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.
85
+
86
+ ## Development
87
+
88
+ 1. Install dependencies with `uv sync` (or `pip install -r requirements.txt` if you export them).
89
+ 2. Run `python -m mcc.main path/to/file.cu` to skip the console entry point while iterating.
90
+ 3. Use `uv run python -m pip install -e .` to get an editable install for local testing.
91
+
92
+ ## Troubleshooting
93
+
94
+ - **`modal.ClientException: Unauthorized`** → Run `modal token new` and try again.
95
+ - **`nvcc failed to compile...`** → Fix compiler errors shown in the streamed stderr or adjust `--nvcc-arg` flags.
96
+ - **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`.
97
+
98
+ ## License
99
+
100
+ MIT © ExpressGradient
@@ -0,0 +1,67 @@
1
+ ## mcc
2
+
3
+ `mcc` is a tiny CLI that compiles and runs a local CUDA C (`.cu`) program on a cloud GPU using [Modal](https://modal.com). 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.
4
+
5
+ ### Highlights
6
+
7
+ - Runs CUDA samples on-demand without managing local GPU drivers.
8
+ - Lets you choose GPU tier (`T4`, `A100`, `H100`, etc.) and container image per run.
9
+ - Accepts extra `nvcc` arguments for fine-grained builds.
10
+ - Wraps the entire workflow (upload → compile → execute → teardown) in a single command.
11
+
12
+ ## Requirements
13
+
14
+ - Python 3.12+
15
+ - A Modal account with CLI access (`modal token new`).
16
+ - Network access that allows Modal to pull the chosen CUDA container image.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ # install from PyPI/TestPyPI
22
+ pip install modal-cuda # exposes the `mcc` command
23
+
24
+ # from source (editable)
25
+ uv sync && uv pip install -e .
26
+ # or: pip install -e .
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```bash
32
+ mcc path/to/program.cu [--gpu GPU] [--image IMAGE] [--timeout SECONDS] [--nvcc-arg FLAG ...]
33
+ ```
34
+
35
+ | Flag | Description |
36
+ | --- | --- |
37
+ | `input` | Path to a `.cu` file. The file must exist and be non-empty. |
38
+ | `--app` | Name of the Modal app; defaults to the source filename. Useful to group runs in the Modal dashboard. |
39
+ | `--gpu` | GPU type to request (`T4`, `L4`, `A10`, `A100`, `A100-40GB`, `A100-80GB`, `L40S`, `H100`, `H200`, `B200`). Defaults to `T4`. |
40
+ | `--image` | Container image reference passed to `modal.Image.from_registry`. Defaults to `nvidia/cuda:13.0.2-cudnn-devel-ubuntu22.04`. |
41
+ | `--timeout` | Execution timeout (seconds) enforced by Modal. Defaults to 600. |
42
+ | `--nvcc-arg` | Additional flag forwarded to `nvcc`. Repeat for multiple flags (e.g., `--nvcc-arg -arch=sm_90`). |
43
+
44
+ Example session:
45
+
46
+ ```bash
47
+ # Run the provided sample kernel on an A100 GPU with verbose PTX output
48
+ mcc sample.cu --gpu A100 --nvcc-arg -Xptxas --nvcc-arg -v
49
+ ```
50
+
51
+ 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.
52
+
53
+ ## Development
54
+
55
+ 1. Install dependencies with `uv sync` (or `pip install -r requirements.txt` if you export them).
56
+ 2. Run `python -m mcc.main path/to/file.cu` to skip the console entry point while iterating.
57
+ 3. Use `uv run python -m pip install -e .` to get an editable install for local testing.
58
+
59
+ ## Troubleshooting
60
+
61
+ - **`modal.ClientException: Unauthorized`** → Run `modal token new` and try again.
62
+ - **`nvcc failed to compile...`** → Fix compiler errors shown in the streamed stderr or adjust `--nvcc-arg` flags.
63
+ - **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`.
64
+
65
+ ## License
66
+
67
+ MIT © ExpressGradient
@@ -0,0 +1,126 @@
1
+ import argparse
2
+ from pathlib import Path
3
+
4
+ import modal
5
+
6
+
7
+ def main():
8
+ parser = argparse.ArgumentParser(
9
+ prog="mcc", description="Compile and Run CUDA C scripts with Modal"
10
+ )
11
+ parser.add_argument("input", help="Input CUDA C file", type=Path)
12
+ parser.add_argument(
13
+ "--app",
14
+ help="App name to run the CUDA script; defaults to the input file name",
15
+ type=str,
16
+ )
17
+ parser.add_argument(
18
+ "--gpu",
19
+ help="Choose the GPU to run the script",
20
+ type=str,
21
+ default="T4",
22
+ choices=[
23
+ "T4",
24
+ "L4",
25
+ "A10",
26
+ "A100",
27
+ "A100-40GB",
28
+ "A100-80GB",
29
+ "L40S",
30
+ "H100",
31
+ "H200",
32
+ "B200",
33
+ ],
34
+ )
35
+ parser.add_argument(
36
+ "--image",
37
+ type=str,
38
+ default="nvidia/cuda:13.0.2-cudnn-devel-ubuntu22.04",
39
+ help="Container image to use for Modal (registry reference)",
40
+ )
41
+ parser.add_argument(
42
+ "--timeout",
43
+ type=int,
44
+ default=60 * 10,
45
+ help="Execution timeout in seconds for the CUDA run (default: 600)",
46
+ )
47
+ parser.add_argument(
48
+ "--nvcc-arg",
49
+ dest="nvcc_args",
50
+ action="append",
51
+ default=None,
52
+ metavar="FLAG",
53
+ help="Extra argument to pass to nvcc; repeat for multiple flags",
54
+ )
55
+
56
+ args = parser.parse_args()
57
+
58
+ if not args.input.exists():
59
+ parser.error(f"File {args.input} not found")
60
+
61
+ if args.input.suffix.lower() != ".cu":
62
+ parser.error("Input file must have a .cu extension")
63
+
64
+ code = args.input.read_text()
65
+ if not code.strip():
66
+ parser.error(f"File {args.input} is empty")
67
+
68
+ app_name = args.app or args.input.name
69
+ cuda_image = modal.Image.from_registry(args.image, add_python="3.12")
70
+ app = modal.App(app_name, image=cuda_image)
71
+
72
+ @app.function(gpu=args.gpu, timeout=args.timeout, serialized=True)
73
+ def compile_and_run_cuda(cuda_source: str, nvcc_args: list[str] | None = None):
74
+ import subprocess
75
+ import uuid
76
+ from pathlib import Path
77
+
78
+ run_id = uuid.uuid4().hex
79
+ source_path = Path(f"/tmp/{run_id}.cu")
80
+ binary_path = Path(f"/tmp/{run_id}")
81
+ source_path.write_text(cuda_source)
82
+
83
+ def _run_command(cmd: list[str]) -> subprocess.CompletedProcess[str]:
84
+ print(f"$ {' '.join(cmd)}")
85
+
86
+ completed = subprocess.run(cmd, capture_output=True, text=True, check=False)
87
+
88
+ if completed.stdout:
89
+ print(completed.stdout)
90
+
91
+ if completed.stderr:
92
+ print(completed.stderr)
93
+
94
+ return completed
95
+
96
+ try:
97
+ extra_args = nvcc_args or []
98
+
99
+ compile_result = _run_command(
100
+ ["nvcc", str(source_path), "-o", str(binary_path), *extra_args]
101
+ )
102
+
103
+ if compile_result.returncode != 0:
104
+ raise RuntimeError("nvcc failed to compile the CUDA source file")
105
+
106
+ execution_result = _run_command([str(binary_path)])
107
+
108
+ if execution_result.returncode != 0:
109
+ raise RuntimeError(
110
+ "Executable exited with a non-zero status while running the CUDA program"
111
+ )
112
+
113
+ return execution_result.stdout
114
+
115
+ finally:
116
+ for path in (source_path, binary_path):
117
+ if path.exists():
118
+ path.unlink()
119
+
120
+ with modal.enable_output():
121
+ with app.run():
122
+ compile_and_run_cuda.remote(code, args.nvcc_args or [])
123
+
124
+
125
+ if __name__ == "__main__":
126
+ main()
@@ -0,0 +1,100 @@
1
+ Metadata-Version: 2.4
2
+ Name: modal-cuda
3
+ Version: 0.1.0
4
+ Summary: CLI that compiles and runs CUDA C programs on Modal GPUs
5
+ Author: ExpressGradient
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 ExpressGradient
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Requires-Python: >=3.12
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: modal>=1.2.2
32
+ Dynamic: license-file
33
+
34
+ ## mcc
35
+
36
+ `mcc` is a tiny CLI that compiles and runs a local CUDA C (`.cu`) program on a cloud GPU using [Modal](https://modal.com). 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.
37
+
38
+ ### Highlights
39
+
40
+ - Runs CUDA samples on-demand without managing local GPU drivers.
41
+ - Lets you choose GPU tier (`T4`, `A100`, `H100`, etc.) and container image per run.
42
+ - Accepts extra `nvcc` arguments for fine-grained builds.
43
+ - Wraps the entire workflow (upload → compile → execute → teardown) in a single command.
44
+
45
+ ## Requirements
46
+
47
+ - Python 3.12+
48
+ - A Modal account with CLI access (`modal token new`).
49
+ - Network access that allows Modal to pull the chosen CUDA container image.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ # install from PyPI/TestPyPI
55
+ pip install modal-cuda # exposes the `mcc` command
56
+
57
+ # from source (editable)
58
+ uv sync && uv pip install -e .
59
+ # or: pip install -e .
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ```bash
65
+ mcc path/to/program.cu [--gpu GPU] [--image IMAGE] [--timeout SECONDS] [--nvcc-arg FLAG ...]
66
+ ```
67
+
68
+ | Flag | Description |
69
+ | --- | --- |
70
+ | `input` | Path to a `.cu` file. The file must exist and be non-empty. |
71
+ | `--app` | Name of the Modal app; defaults to the source filename. Useful to group runs in the Modal dashboard. |
72
+ | `--gpu` | GPU type to request (`T4`, `L4`, `A10`, `A100`, `A100-40GB`, `A100-80GB`, `L40S`, `H100`, `H200`, `B200`). Defaults to `T4`. |
73
+ | `--image` | Container image reference passed to `modal.Image.from_registry`. Defaults to `nvidia/cuda:13.0.2-cudnn-devel-ubuntu22.04`. |
74
+ | `--timeout` | Execution timeout (seconds) enforced by Modal. Defaults to 600. |
75
+ | `--nvcc-arg` | Additional flag forwarded to `nvcc`. Repeat for multiple flags (e.g., `--nvcc-arg -arch=sm_90`). |
76
+
77
+ Example session:
78
+
79
+ ```bash
80
+ # Run the provided sample kernel on an A100 GPU with verbose PTX output
81
+ mcc sample.cu --gpu A100 --nvcc-arg -Xptxas --nvcc-arg -v
82
+ ```
83
+
84
+ 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.
85
+
86
+ ## Development
87
+
88
+ 1. Install dependencies with `uv sync` (or `pip install -r requirements.txt` if you export them).
89
+ 2. Run `python -m mcc.main path/to/file.cu` to skip the console entry point while iterating.
90
+ 3. Use `uv run python -m pip install -e .` to get an editable install for local testing.
91
+
92
+ ## Troubleshooting
93
+
94
+ - **`modal.ClientException: Unauthorized`** → Run `modal token new` and try again.
95
+ - **`nvcc failed to compile...`** → Fix compiler errors shown in the streamed stderr or adjust `--nvcc-arg` flags.
96
+ - **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`.
97
+
98
+ ## License
99
+
100
+ MIT © ExpressGradient
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ main.py
4
+ pyproject.toml
5
+ modal_cuda.egg-info/PKG-INFO
6
+ modal_cuda.egg-info/SOURCES.txt
7
+ modal_cuda.egg-info/dependency_links.txt
8
+ modal_cuda.egg-info/entry_points.txt
9
+ modal_cuda.egg-info/requires.txt
10
+ modal_cuda.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcc = main:main
@@ -0,0 +1 @@
1
+ modal>=1.2.2
@@ -0,0 +1,14 @@
1
+ [project]
2
+ name = "modal-cuda"
3
+ version = "0.1.0"
4
+ description = "CLI that compiles and runs CUDA C programs on Modal GPUs"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = { file = "LICENSE" }
8
+ authors = [{ name = "ExpressGradient" }]
9
+ dependencies = [
10
+ "modal>=1.2.2",
11
+ ]
12
+
13
+ [project.scripts]
14
+ mcc = "main:main"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+