gpubox 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.
- gpubox-0.1.0/.gitignore +5 -0
- gpubox-0.1.0/LICENSE +202 -0
- gpubox-0.1.0/PKG-INFO +415 -0
- gpubox-0.1.0/README.md +398 -0
- gpubox-0.1.0/pyproject.toml +44 -0
- gpubox-0.1.0/src/gpubox/__init__.py +26 -0
- gpubox-0.1.0/src/gpubox/api.py +1018 -0
- gpubox-0.1.0/src/gpubox/cli.py +823 -0
- gpubox-0.1.0/src/gpubox/errors.py +51 -0
- gpubox-0.1.0/src/gpubox/gate.py +482 -0
- gpubox-0.1.0/src/gpubox/job.py +507 -0
- gpubox-0.1.0/src/gpubox/launch.py +1029 -0
- gpubox-0.1.0/src/gpubox/onbox.py +47 -0
- gpubox-0.1.0/src/gpubox/policy.py +179 -0
- gpubox-0.1.0/src/gpubox/providers/__init__.py +99 -0
- gpubox-0.1.0/src/gpubox/providers/base.py +100 -0
- gpubox-0.1.0/src/gpubox/providers/container.py +127 -0
- gpubox-0.1.0/src/gpubox/providers/httpapi.py +93 -0
- gpubox-0.1.0/src/gpubox/providers/hyperstack.py +411 -0
- gpubox-0.1.0/src/gpubox/providers/lyceum.py +243 -0
- gpubox-0.1.0/src/gpubox/providers/massed.py +330 -0
- gpubox-0.1.0/src/gpubox/providers/runpod.py +324 -0
- gpubox-0.1.0/src/gpubox/providers/shadeform.py +382 -0
- gpubox-0.1.0/src/gpubox/providers/slurm.py +513 -0
- gpubox-0.1.0/src/gpubox/providers/vast.py +464 -0
- gpubox-0.1.0/src/gpubox/providers/vmbox.py +155 -0
- gpubox-0.1.0/src/gpubox/sshconfig.py +144 -0
- gpubox-0.1.0/src/gpubox/state.py +255 -0
- gpubox-0.1.0/src/gpubox/store.py +397 -0
gpubox-0.1.0/.gitignore
ADDED
gpubox-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
gpubox-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: gpubox
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rent and verify GPU dev boxes with automatic cleanup where supported
|
|
5
|
+
Project-URL: Repository, https://github.com/tridao/gpubox
|
|
6
|
+
Project-URL: Issues, https://github.com/tridao/gpubox/issues
|
|
7
|
+
Author: Tri Dao
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# gpubox
|
|
19
|
+
|
|
20
|
+
Rent a GPU box from [Vast.ai](https://vast.ai), [RunPod](https://runpod.io) or
|
|
21
|
+
the VM clouds behind [Shadeform](https://shadeform.ai), or take one from a
|
|
22
|
+
Slurm cluster. gpubox checks that it works and manages its teardown.
|
|
23
|
+
For CI jobs and dev boxes.
|
|
24
|
+
|
|
25
|
+
Marketplace hosts are unreliable: some never finish pulling the image, some
|
|
26
|
+
come up with a GPU that is already busy. gpubox rents two at once, keeps the
|
|
27
|
+
first that passes a health check, and destroys the other. Run `gpubox down`
|
|
28
|
+
when done and schedule `gpubox reap --namespace NS --destroy` as a fallback.
|
|
29
|
+
Some providers enforce expiry, but others rely on the reaper, as do rentals
|
|
30
|
+
whose own lease timer never starts or is stopped by preemption.
|
|
31
|
+
|
|
32
|
+
The controller runs on Linux or macOS with Python 3.10+ and OpenSSH (`ssh`
|
|
33
|
+
and `ssh-keygen`). No third-party Python dependencies.
|
|
34
|
+
[DESIGN.md](https://github.com/tridao/gpubox/blob/main/DESIGN.md) explains how
|
|
35
|
+
it works, what it assumes, and what was measured.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install gpubox
|
|
41
|
+
export VASTAI_API_KEY=...
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For a one-off CLI invocation, use `uvx gpubox --help`. In CI, pin a version
|
|
45
|
+
(`pip install gpubox==0.1.0`): the job that runs gpubox holds your provider
|
|
46
|
+
key. To install unreleased changes, pin a Git commit instead:
|
|
47
|
+
`pip install 'git+https://github.com/tridao/gpubox@<commit>'`.
|
|
48
|
+
|
|
49
|
+
Keys are read from the environment (`VASTAI_API_KEY`, `RUNPOD_API_KEY`,
|
|
50
|
+
`SHADEFORM_API_KEY`), else from lines `NAME=value` in
|
|
51
|
+
`~/.config/gpu-cloud-query/keys.env`.
|
|
52
|
+
|
|
53
|
+
## A dev box
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
gpubox up --gpu "RTX 4090" --max-dph-per-gpu 0.60 --image my/image:tag \
|
|
57
|
+
--namespace dev --name mybox --ttl-min 480 --ssh-config
|
|
58
|
+
ssh mybox # also scp, rsync, editors
|
|
59
|
+
gpubox ssh -- nvidia-smi # the same with the run's key, no ~/.ssh/config needed
|
|
60
|
+
gpubox renew --ttl-min 480 # the lease now ends 8 hours from now
|
|
61
|
+
gpubox down
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`--ssh-config` adds a `Host mybox` entry to `~/.ssh/gpubox_config` and one
|
|
65
|
+
`Include` line at the top of `~/.ssh/config`. `down` removes the entry.
|
|
66
|
+
|
|
67
|
+
`--gpu` can be repeated to accept any of several models (the cheapest offer
|
|
68
|
+
goes first). `--min-cpus` and `--min-ram-gb` are for the whole box; by
|
|
69
|
+
default it gets max(16, 8 per GPU) CPUs and 32 GB of RAM per GPU.
|
|
70
|
+
`--min-cuda` (default 13.0) is the lowest CUDA version the host's driver must
|
|
71
|
+
support: a CUDA 13.x image runs on any 13.x driver but not on a 12.x one.
|
|
72
|
+
A box whose driver turns out too old for the image's PyTorch fails without
|
|
73
|
+
the machine being blamed, and offers with drivers as old are skipped.
|
|
74
|
+
|
|
75
|
+
A private image: `--registry-user USER` with the token in
|
|
76
|
+
`GPUBOX_REGISTRY_TOKEN` (the registry comes from the image name). Vast and
|
|
77
|
+
the host's docker daemon see the token, so make it a read-only pull token.
|
|
78
|
+
|
|
79
|
+
`--interruptible` rents interruptible boxes, bidding `--bid-markup` (1.25)
|
|
80
|
+
times each offer's minimum bid; the price cap applies to the bid with the
|
|
81
|
+
disk. An outbid box is stopped: its job dies, and the box keeps billing its
|
|
82
|
+
disk, with its lease timer stopped too, until something destroys it. So run
|
|
83
|
+
`gpubox reap --namespace NS --destroy` on a schedule, and expect `wait` to
|
|
84
|
+
report a lost job (75). Two launches in different state directories can still
|
|
85
|
+
bid on one machine at the same moment: the account's boxes are looked at
|
|
86
|
+
once, when a launch starts. Machines
|
|
87
|
+
the account already has a box on are skipped (our own bids would outbid each
|
|
88
|
+
other), and a box that stops or never starts is not held against its machine.
|
|
89
|
+
|
|
90
|
+
A large image needs a longer `--startup-timeout` than the default 300 s,
|
|
91
|
+
which counts from the rental and so includes the image pull.
|
|
92
|
+
|
|
93
|
+
## Jobs
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
gpubox run --script train.sh --env WANDB_API_KEY --timeout-min 600
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`run` starts the script on the box in a session of its own and streams its
|
|
100
|
+
output. The job does not depend on the connection: a dropped connection is
|
|
101
|
+
picked up where it was (for up to `--reconnect-min`, 10), and Ctrl-C stops
|
|
102
|
+
the streaming, not the job. `--detach` prints the job id and returns at once.
|
|
103
|
+
Then:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
gpubox logs -f [JOB] # its output, until it ends; its exit code
|
|
107
|
+
gpubox wait [JOB] # just the exit code
|
|
108
|
+
gpubox jobs # every job on the box: exit code, running or lost
|
|
109
|
+
gpubox kill [JOB]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
(`JOB` defaults to the newest.) The box itself ends a job at `--timeout-min`
|
|
113
|
+
(default 60; 0 for never), with exit 124. `--destroy-after` destroys the box
|
|
114
|
+
when the script ends; a job can also run `gpubox-destroy-self` on the box
|
|
115
|
+
whenever it is done.
|
|
116
|
+
|
|
117
|
+
The job sees the image's environment (Docker `ENV`, saved when the box
|
|
118
|
+
starts; so do `ssh` sessions), then `--env` variables, then `GPUBOX_RUN_ID`,
|
|
119
|
+
`GPUBOX_JOB`, `GPUBOX_BOX_INDEX`, `GPUBOX_BOX_COUNT` and `GPUBOX_BOX_NAME`.
|
|
120
|
+
gpubox replaces the image's `ENTRYPOINT` to start its own sshd and timer: a
|
|
121
|
+
job that needs the entrypoint's setup runs it itself
|
|
122
|
+
(`exec /entrypoint.sh python -m my.job`).
|
|
123
|
+
|
|
124
|
+
**Secrets.** `--env NAME` (no `=`) takes the value from gpubox's own
|
|
125
|
+
environment, so it is on no command line: `op run -- gpubox run ...`, a CI
|
|
126
|
+
secret, Doppler and the like all work the same way. `--env-file FILE` reads
|
|
127
|
+
`NAME=VALUE` lines. Values go over SSH into a file only root can read, which
|
|
128
|
+
the job reads and deletes as it starts; they are never in Vast's instance
|
|
129
|
+
settings. The host's operator has root on the machine, so send only
|
|
130
|
+
credentials you can revoke: scoped, short-lived where possible.
|
|
131
|
+
|
|
132
|
+
## Several boxes
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
gpubox up --count 4 --gpu "RTX 5090" --max-dph-per-gpu 0.80 --image my/image:tag \
|
|
136
|
+
--namespace eval --name shard --ttl-min 240 --ssh-config
|
|
137
|
+
gpubox status # shard-0 ... shard-3: addresses, lease
|
|
138
|
+
ssh shard-2
|
|
139
|
+
gpubox run --box 2 --script job.sh
|
|
140
|
+
gpubox run --all --script shard.sh # on every box: $GPUBOX_BOX_INDEX says which
|
|
141
|
+
gpubox down # all of them
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
All or nothing: `up` races `count + --spare` hosts and returns 0 only with
|
|
145
|
+
`--count` healthy boxes; otherwise it destroys the ones it had. A run of one
|
|
146
|
+
box is called `NAME`; a run of several, `NAME-0`, `NAME-1`, ...
|
|
147
|
+
|
|
148
|
+
## RunPod
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
gpubox search --provider runpod --gpu "RTX 4090" --max-dph-per-gpu 0.80
|
|
152
|
+
gpubox up --provider runpod --gpu "RTX 4090" --max-dph-per-gpu 0.80 --image my/image:tag \
|
|
153
|
+
--namespace dev --name mybox --ttl-min 240 --ssh-config
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The same as on Vast, with RunPod's pods: the race, the gate, jobs, `ssh`,
|
|
157
|
+
`renew` and the lease all work as they do there. RunPod chooses the machine:
|
|
158
|
+
an offer is a GPU type in a data center that has it in stock, at RunPod's
|
|
159
|
+
list price, and `--gpu` matches its names ("RTX 4090" matches "NVIDIA GeForce
|
|
160
|
+
RTX 4090"; without `--gpu`, any model under the price cap). A pod deletes
|
|
161
|
+
itself when its lease ends, with the key RunPod gives each pod.
|
|
162
|
+
`--runpod-cloud community` rents community hosts instead of RunPod's own
|
|
163
|
+
data centers.
|
|
164
|
+
|
|
165
|
+
As everywhere, `--min-cpus` and `--min-ram-gb` default to max(16, 8 per GPU)
|
|
166
|
+
CPUs and 32 GB per GPU: pass smaller ones to admit RunPod's smaller pods.
|
|
167
|
+
|
|
168
|
+
Not yet on RunPod: `--interruptible`, `--registry-user` (private images) and
|
|
169
|
+
`--exclude-country`; and machines are not recorded (RunPod's API does not
|
|
170
|
+
name them), so the blocklist does not apply. An image that cannot be pulled
|
|
171
|
+
is not recognised as such: each pod is given up on after `--stall-timeout`.
|
|
172
|
+
|
|
173
|
+
## Shadeform (VM clouds)
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
gpubox search --provider shadeform --gpu A6000 --max-dph-per-gpu 0.80
|
|
177
|
+
gpubox up --provider shadeform --gpu A6000 --max-dph-per-gpu 0.80 --image my/image:tag \
|
|
178
|
+
--namespace dev --name mybox --ttl-min 120 --overall-timeout 1500
|
|
179
|
+
gpubox ssh # a shell in the box's container
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Shadeform rents VMs on Hyperstack, Massed Compute, Lambda, Crusoe, Nebius
|
|
183
|
+
and others with one key. A box there is your image run as a container on
|
|
184
|
+
the VM: gpubox gives the VM a startup script that adds the run's key and
|
|
185
|
+
starts the image, and reaches the box with SSH to the VM and `docker exec`,
|
|
186
|
+
so the image needs no sshd (but, as everywhere, bash and python3). An offer
|
|
187
|
+
is an instance type in a region, booted with Shadeform's own OS image with
|
|
188
|
+
the newest CUDA, which must be at least `--min-cuda` (13.0 by default: pass
|
|
189
|
+
`--min-cuda 12.8` for an image built for CUDA 12). VMs take 5 to 8 minutes
|
|
190
|
+
to boot; the start-up and stall limits count from when Shadeform expects
|
|
191
|
+
the boot to end, but `--overall-timeout` should allow for it.
|
|
192
|
+
|
|
193
|
+
The lease is Shadeform's own: the VM is created with an auto-delete time,
|
|
194
|
+
which `renew` moves. A VM cannot delete itself, so `run --destroy-after` is
|
|
195
|
+
refused. Not yet: `--ssh-config`, `--registry-user`, `--interruptible`,
|
|
196
|
+
`--exclude-country`, `--account-id`.
|
|
197
|
+
|
|
198
|
+
## Hyperstack
|
|
199
|
+
|
|
200
|
+
`--provider hyperstack` (`HYPERSTACK_API_KEY`) rents Hyperstack's VMs
|
|
201
|
+
directly, as boxes like Shadeform's: the image as a container on the VM,
|
|
202
|
+
reached with SSH and `docker exec`, booted with Hyperstack's image "with
|
|
203
|
+
Docker" of the newest CUDA in the region. Hyperstack keeps no expiry and a
|
|
204
|
+
VM cannot delete itself, so `up` warns: only `gpubox down`, or a scheduled
|
|
205
|
+
`gpubox reap --provider hyperstack --namespace NS --destroy`, ends a VM left
|
|
206
|
+
behind. Hyperstack needs a key pair at the create: if the environment has
|
|
207
|
+
none, the run's public key is imported once as `gpubox`.
|
|
208
|
+
|
|
209
|
+
## Massed Compute
|
|
210
|
+
|
|
211
|
+
`--provider massed` (`MASSED_COMPUTE_API_KEY`) rents Massed Compute's VMs
|
|
212
|
+
directly, through its MCP server, as boxes like Shadeform's, on Massed's
|
|
213
|
+
"Ubuntu Server 22.04 w/ drivers" (NVIDIA drivers and docker). Its 1-GPU
|
|
214
|
+
products have 6 CPUs and 32 GB: pass `--min-cpus 6`. Massed cannot rename an
|
|
215
|
+
instance, so the lease set by `up --ttl-min` cannot be moved (`renew` is
|
|
216
|
+
refused), and as on Hyperstack only `down` or a scheduled `reap` ends a VM
|
|
217
|
+
left behind.
|
|
218
|
+
|
|
219
|
+
## Lyceum
|
|
220
|
+
|
|
221
|
+
`--provider lyceum` (`LYCEUM_API_KEY`) rents Lyceum's VMs, as boxes like
|
|
222
|
+
Shadeform's. Lyceum runs nothing of ours at boot, so the first probe that
|
|
223
|
+
gets in sends the box's setup and starts it. Its region and disk (500 GB)
|
|
224
|
+
are its own choice; as on Hyperstack only `down` or a scheduled `reap` ends
|
|
225
|
+
a VM left behind.
|
|
226
|
+
|
|
227
|
+
## A Slurm cluster
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
gpubox up --provider slurm --login mycluster --num-gpus 1 --gpu H100 \
|
|
231
|
+
--namespace dev --name mybox --ttl-min 240
|
|
232
|
+
gpubox ssh # a shell in the allocation
|
|
233
|
+
gpubox run --script job.sh # detached; follows its output
|
|
234
|
+
gpubox down
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
A box is one batch job holding an allocation (`--gres=gpu:N`, and
|
|
238
|
+
`--min-cpus`, `--min-ram-gb` if given; otherwise the cluster's defaults).
|
|
239
|
+
gpubox runs Slurm's commands on the login host over your own SSH
|
|
240
|
+
configuration, so `ssh mycluster squeue` must work without a password
|
|
241
|
+
prompt (keys, or a ControlMaster opened beforehand), and the login shell
|
|
242
|
+
must be POSIX; Slurm must be 20.11 or later (`srun --overlap`). Everything
|
|
243
|
+
runs in the nodes' own environment: `--image` is not used.
|
|
244
|
+
|
|
245
|
+
`--partition`, `--slurm-account`, `--qos`, `--constraint` and
|
|
246
|
+
`--sbatch-arg OPTION` (repeatable) go to sbatch. A request the cluster can
|
|
247
|
+
never satisfy (no such partition, too many GPUs, a time limit above the
|
|
248
|
+
partition's) is a configuration error at once. Time in the queue is nobody's
|
|
249
|
+
fault: `--startup-timeout` and `--stall-timeout` count from when the job
|
|
250
|
+
starts, and only `--overall-timeout` bounds the wait. `--spare` is 0 by
|
|
251
|
+
default here; a node that fails the gate is excluded from the jobs submitted
|
|
252
|
+
after it.
|
|
253
|
+
|
|
254
|
+
The lease is kept twice: by the job's own script, which ends the job when the
|
|
255
|
+
lease ends, and by Slurm's time limit, set two minutes past it. `renew` moves
|
|
256
|
+
both; a cluster that does not let users extend a time limit refuses it, and
|
|
257
|
+
the box then ends at its old one. Commands reach a box with
|
|
258
|
+
`srun --jobid=ID --overlap`, so they get its GPUs (`CUDA_VISIBLE_DEVICES`),
|
|
259
|
+
CPUs and environment; jobs started by `run` are started by the batch script,
|
|
260
|
+
since Slurm ends whatever a step started when the step ends. The gate looks
|
|
261
|
+
only at the allocation's GPUs. Not available: `--ssh-config`, `search`, and
|
|
262
|
+
the machine blocklist and reputation store, which are about Vast's machines.
|
|
263
|
+
|
|
264
|
+
## A CI job
|
|
265
|
+
|
|
266
|
+
```yaml
|
|
267
|
+
- id: up
|
|
268
|
+
run: >
|
|
269
|
+
gpubox up --gpu "RTX 5090" --num-gpus 2 --max-dph-per-gpu 1.25
|
|
270
|
+
--image my/ci-image:tag --namespace my-ci
|
|
271
|
+
--name "${{ github.run_id }}-${{ github.run_attempt }}" --ttl-min 60
|
|
272
|
+
- run: gpubox run --script remote.sh --env "SHA=${{ github.sha }}" --timeout-min 40
|
|
273
|
+
- if: always() && steps.up.outputs.run_id != ''
|
|
274
|
+
run: gpubox down --run-id "${{ steps.up.outputs.run_id }}"
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
and, from a schedule every half hour:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
gpubox reap --namespace my-ci --destroy
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
`up` writes the run id as a step output before it rents anything. Passing it
|
|
284
|
+
to `down` lets the teardown work even from a runner that has lost the state
|
|
285
|
+
directory. Always run `down` after `up`, whatever `up` returned.
|
|
286
|
+
|
|
287
|
+
## From Python
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
import gpubox
|
|
291
|
+
|
|
292
|
+
spec = gpubox.Spec(image="ghcr.io/org/img:1", gpus=("RTX 5090", "RTX 4090"),
|
|
293
|
+
max_dph_per_gpu=1.0, min_cpus=12, min_ram_gb=64, ttl_min=240)
|
|
294
|
+
with gpubox.up(spec, namespace="eval", name="shard", count=4) as run:
|
|
295
|
+
jobs = run.start(open("shard.sh").read(), env={"TOKEN": token}, timeout_min=180)
|
|
296
|
+
outcomes = gpubox.wait_all(jobs) # per job: .code, or .error
|
|
297
|
+
# the boxes are destroyed when the block ends, however it ends (run.keep() to keep them)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
If `up` fails or is interrupted after it began the run, it tears the run down
|
|
301
|
+
before raising (and says how to retry if that fails too). A `Run` is a
|
|
302
|
+
handle, not a lock: once the run is torn down or replaced in its state
|
|
303
|
+
directory, whatever would touch its boxes raises `StateError`.
|
|
304
|
+
|
|
305
|
+
`gpubox.attach(state_dir)` picks up a run left in a state directory (also by
|
|
306
|
+
the command line); `run.boxes[i]` has `ssh_argv`, `sh`, `start`, `job`,
|
|
307
|
+
`jobs`; a `Job` has `wait`, `logs` and `kill`. `gpubox.down(run_id=...)` and
|
|
308
|
+
`gpubox.reap(namespace)` are the teardowns. Failures are exceptions:
|
|
309
|
+
`ConfigError` and `StateError` for our own mistakes, `InfraError` (`NoBoxes`,
|
|
310
|
+
`TeardownIncomplete`, `BoxLost`, `JobLost`) for the provider's or a box's.
|
|
311
|
+
`gpubox.set_log(fn)` sends what it says somewhere other than stdout, for the
|
|
312
|
+
whole process. The command line is a thin layer over this (`gpubox/api.py`).
|
|
313
|
+
Elsewhere than Vast, pass `provider="runpod"`, or `provider="slurm",
|
|
314
|
+
options={"login": "mycluster", ...}`, to `up` (and to `down(run_id=...)`,
|
|
315
|
+
`reap` and `search`); a run remembers where its boxes came from.
|
|
316
|
+
|
|
317
|
+
## Commands
|
|
318
|
+
|
|
319
|
+
| | |
|
|
320
|
+
|---|---|
|
|
321
|
+
| `up` | rent boxes (`--count`, default 1) and wait until they pass the health gate; `--provider runpod`, `shadeform` or `slurm` for those |
|
|
322
|
+
| `status` | show the run's boxes: names, addresses, lease |
|
|
323
|
+
| `run` | start a local script on a box, detached, and stream its output |
|
|
324
|
+
| `logs` | a job's output (`-f`: until it ends) |
|
|
325
|
+
| `wait` | wait for a job to end |
|
|
326
|
+
| `jobs` | the jobs on a box |
|
|
327
|
+
| `kill` | stop a job |
|
|
328
|
+
| `ssh` | a shell on a box, or `-- CMD` run there |
|
|
329
|
+
| `renew` | move the end of the boxes' lease |
|
|
330
|
+
| `down` | destroy everything the run rented |
|
|
331
|
+
| `reap` | destroy boxes of a namespace whose lease has ended (without `--destroy`: report) |
|
|
332
|
+
| `search` | show the offers `up` would try; rents nothing |
|
|
333
|
+
|
|
334
|
+
Exit codes: 0 ok; 2 configuration (bad arguments, no API key, an image that
|
|
335
|
+
cannot be pulled or does not start our sshd); 75 infrastructure (no healthy
|
|
336
|
+
box, box lost mid-run, teardown not confirmed); 124 script timeout; 130
|
|
337
|
+
interrupted. `run`, `wait` and `logs -f` otherwise return the job's own exit
|
|
338
|
+
code.
|
|
339
|
+
|
|
340
|
+
State lives in `--state-dir` (default `.gpubox`): `run.json`, an SSH key per
|
|
341
|
+
run, and `observations.jsonl`.
|
|
342
|
+
|
|
343
|
+
## How it works
|
|
344
|
+
|
|
345
|
+
- **Race.** `up` rents `--count + --spare` hosts (2 by default), cheapest
|
|
346
|
+
first, one machine per host. A box that fails is destroyed and replaced, up
|
|
347
|
+
to `--max-attempts` rentals (default `2 * count + 4`).
|
|
348
|
+
- **Health gate.** GPU model, count and VRAM; required URLs reachable
|
|
349
|
+
(`--must-reach`); the GPU idle before we touch it. Where the image has a
|
|
350
|
+
CUDA build of PyTorch, also: CUDA works, a matmul on every GPU matches the
|
|
351
|
+
CPU, and most of the VRAM can be allocated. It needs `python3` in the image.
|
|
352
|
+
- **Your own checks.** `--gate-script FILE` runs on each box after the gate
|
|
353
|
+
passes (by its `#!` line, else bash; at most `--gate-timeout` seconds).
|
|
354
|
+
Exit 0 admits the box; anything else fails it and another is tried. To
|
|
355
|
+
have the machine blocklisted, print a last line
|
|
356
|
+
`{"ok": false, "reason": "no_network", "detail": "..."}` with one of the
|
|
357
|
+
gate's reason codes (`policy.REASONS`).
|
|
358
|
+
- **Tag.** Every box is labelled `<namespace>.<name>.<random>.a<n>.<expiry>`
|
|
359
|
+
when it is rented. Anything that knows the run id can find the run's boxes
|
|
360
|
+
and destroy them.
|
|
361
|
+
- **Lease.** The lease ends `--ttl-min` after `up` started. A timer on the
|
|
362
|
+
box or the provider enforces it where supported. A scheduled `reap`
|
|
363
|
+
destroys expired boxes when there is no timer or it could not run.
|
|
364
|
+
`renew` moves the end on providers that support it.
|
|
365
|
+
- **Blocklist.** A machine that failed in a launch that succeeded is skipped for 2 hours to 14 days, depending on why
|
|
366
|
+
(`observations.jsonl`; cache it between CI runs). A launch that failed
|
|
367
|
+
blames nobody.
|
|
368
|
+
- **Defaults from measurement.** Hosts in mainland China are skipped
|
|
369
|
+
(`--exclude-country`, default `CN`; `none` to skip none). A box whose
|
|
370
|
+
loading status has not changed for `--stall-timeout` (300 s) is replaced.
|
|
371
|
+
|
|
372
|
+
## What it promises, and what it does not
|
|
373
|
+
|
|
374
|
+
- `up` exits 0 only with `--count` boxes that passed the gate, were still
|
|
375
|
+
running when looked up afterwards, and are recorded in `run.json`. Before that, a failure
|
|
376
|
+
or Ctrl-C rolls back what was rented. The rollback gets about ten seconds
|
|
377
|
+
and is an attempt; `down` finishes it.
|
|
378
|
+
- At most `--count + --spare` boxes are billable at once, as far as gpubox
|
|
379
|
+
can know. A rental request that got no answer keeps its slot.
|
|
380
|
+
- No offer above the price cap is rented, whatever the search returned.
|
|
381
|
+
- `down` exits 0 only when every box it knows of is confirmed gone by id and
|
|
382
|
+
two listings in a row show nothing with the run's tag. Otherwise it exits
|
|
383
|
+
75 and says what is left and what to do.
|
|
384
|
+
- Not promised: a maximum lifetime. With no working lease timer or
|
|
385
|
+
provider-enforced expiry, a box that `down` missed can keep billing until
|
|
386
|
+
the reaper removes it. Nothing here finds a box that was renamed, or that
|
|
387
|
+
the provider does not list. There is no spending cap across runs.
|
|
388
|
+
|
|
389
|
+
`--account-id` (or `GPUBOX_ACCOUNT_ID`) makes every command refuse an API key
|
|
390
|
+
that belongs to another account.
|
|
391
|
+
|
|
392
|
+
## Sharing what machines did
|
|
393
|
+
|
|
394
|
+
Optional. With `GPUBOX_STORE_URL` and `GPUBOX_STORE_TOKEN` set, observations
|
|
395
|
+
of machines are shared through a small Cloudflare Worker (`store/`), so that
|
|
396
|
+
a machine that failed for one client is skipped by the others. It is
|
|
397
|
+
advisory: it costs a command a few seconds at most and never fails it.
|
|
398
|
+
|
|
399
|
+
## Development checks
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
python3 -m pip install pytest pre-commit
|
|
403
|
+
pre-commit install # lint and format staged Python files with Ruff
|
|
404
|
+
pre-commit run --all-files
|
|
405
|
+
(cd store && npm ci && npm test) # Node 24 LTS; also enables the Python/Worker integration test
|
|
406
|
+
python3 -m pytest # fake provider and fake SSH; rents nothing
|
|
407
|
+
python3 tests/mutations.py # breaks each behaviour in turn; a test named for it must fail
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
On PRs and pushes to `main`, GitHub Actions runs the hooks, tests Python 3.10
|
|
411
|
+
and current Python 3, and checks the metadata and installation of both the
|
|
412
|
+
wheel and the source distribution.
|
|
413
|
+
The current-Python job also tests the Worker and Python client against local D1.
|
|
414
|
+
All jobs use GitHub-hosted Ubuntu runners; no GPUs or cloud credentials are
|
|
415
|
+
needed. Mutation tests run weekly or on demand (Actions → Mutation tests).
|