gpubk 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.
- gpubk-0.1.0/CHANGELOG.md +39 -0
- gpubk-0.1.0/LICENSE +201 -0
- gpubk-0.1.0/MANIFEST.in +8 -0
- gpubk-0.1.0/PKG-INFO +298 -0
- gpubk-0.1.0/README.md +260 -0
- gpubk-0.1.0/README.zh-CN.md +244 -0
- gpubk-0.1.0/RELEASING.md +61 -0
- gpubk-0.1.0/SECURITY.md +27 -0
- gpubk-0.1.0/benchmarks/scheduler_queue.py +70 -0
- gpubk-0.1.0/pyproject.toml +75 -0
- gpubk-0.1.0/setup.cfg +4 -0
- gpubk-0.1.0/src/bk/__init__.py +3 -0
- gpubk-0.1.0/src/bk/__main__.py +6 -0
- gpubk-0.1.0/src/bk/advisor.py +119 -0
- gpubk-0.1.0/src/bk/allocator.py +264 -0
- gpubk-0.1.0/src/bk/cli.py +1259 -0
- gpubk-0.1.0/src/bk/config.py +233 -0
- gpubk-0.1.0/src/bk/data/codex-skill/gpubk/SKILL.md +76 -0
- gpubk-0.1.0/src/bk/data/codex-skill/gpubk/agents/openai.yaml +4 -0
- gpubk-0.1.0/src/bk/data/codex-skill/gpubk/references/protocol.md +61 -0
- gpubk-0.1.0/src/bk/data/systemd/bk-monitor.service +16 -0
- gpubk-0.1.0/src/bk/data/systemd/bk-worker.service +16 -0
- gpubk-0.1.0/src/bk/fileio.py +65 -0
- gpubk-0.1.0/src/bk/gpu.py +347 -0
- gpubk-0.1.0/src/bk/identity.py +16 -0
- gpubk-0.1.0/src/bk/mcp_server.py +370 -0
- gpubk-0.1.0/src/bk/models.py +79 -0
- gpubk-0.1.0/src/bk/monitor.py +658 -0
- gpubk-0.1.0/src/bk/policy.py +62 -0
- gpubk-0.1.0/src/bk/schedule_index.py +78 -0
- gpubk-0.1.0/src/bk/scheduler.py +1315 -0
- gpubk-0.1.0/src/bk/service.py +570 -0
- gpubk-0.1.0/src/bk/skill.py +67 -0
- gpubk-0.1.0/src/bk/storage.py +461 -0
- gpubk-0.1.0/src/bk/systemd.py +60 -0
- gpubk-0.1.0/src/bk/timeparse.py +88 -0
- gpubk-0.1.0/src/bk/tui.py +2190 -0
- gpubk-0.1.0/src/bk/usage.py +306 -0
- gpubk-0.1.0/src/bk/worker.py +768 -0
- gpubk-0.1.0/src/gpubk.egg-info/PKG-INFO +298 -0
- gpubk-0.1.0/src/gpubk.egg-info/SOURCES.txt +65 -0
- gpubk-0.1.0/src/gpubk.egg-info/dependency_links.txt +1 -0
- gpubk-0.1.0/src/gpubk.egg-info/entry_points.txt +3 -0
- gpubk-0.1.0/src/gpubk.egg-info/requires.txt +10 -0
- gpubk-0.1.0/src/gpubk.egg-info/top_level.txt +1 -0
- gpubk-0.1.0/tests/test_advisor.py +79 -0
- gpubk-0.1.0/tests/test_allocator.py +274 -0
- gpubk-0.1.0/tests/test_cli.py +584 -0
- gpubk-0.1.0/tests/test_config.py +134 -0
- gpubk-0.1.0/tests/test_fileio.py +55 -0
- gpubk-0.1.0/tests/test_gpu.py +105 -0
- gpubk-0.1.0/tests/test_identity.py +32 -0
- gpubk-0.1.0/tests/test_mcp_integration.py +128 -0
- gpubk-0.1.0/tests/test_mcp_server.py +128 -0
- gpubk-0.1.0/tests/test_monitor.py +285 -0
- gpubk-0.1.0/tests/test_policy.py +77 -0
- gpubk-0.1.0/tests/test_release.py +120 -0
- gpubk-0.1.0/tests/test_schedule_index.py +107 -0
- gpubk-0.1.0/tests/test_scheduler.py +443 -0
- gpubk-0.1.0/tests/test_service.py +156 -0
- gpubk-0.1.0/tests/test_skill.py +50 -0
- gpubk-0.1.0/tests/test_storage.py +338 -0
- gpubk-0.1.0/tests/test_systemd.py +43 -0
- gpubk-0.1.0/tests/test_timeparse.py +23 -0
- gpubk-0.1.0/tests/test_tui.py +1019 -0
- gpubk-0.1.0/tests/test_usage.py +98 -0
- gpubk-0.1.0/tests/test_worker.py +226 -0
gpubk-0.1.0/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes are documented here. The project follows Semantic Versioning once a public release is published.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 - 2026-07-12
|
|
6
|
+
|
|
7
|
+
- Use a concise English README by default and ship a matching Simplified Chinese guide in source distributions.
|
|
8
|
+
- Adopt GPUbk as the public project brand and `gpubk` as the PyPI distribution while retaining the `bk` command and protocol namespace.
|
|
9
|
+
- Add 5-minute shared/exclusive scheduling with atomic queueing and VRAM admission.
|
|
10
|
+
- Add compact curses TUI, date/weekday timeline, shared lanes, and interactive Add/Edit.
|
|
11
|
+
- Add NVML monitoring, privacy-safe usage audits, historical load forecasts, and live-aware placement.
|
|
12
|
+
- Add per-user scheduled job workers with private specs and automatic `CUDA_VISIBLE_DEVICES`.
|
|
13
|
+
- Add WAL recovery, configurable private/shared file modes, backups, and concurrent-process tests.
|
|
14
|
+
- Add stable JSON agent context/recommendation, advisory external allocator protocol, MCP server, and bundled Codex Skill.
|
|
15
|
+
- Bind audit display names to the process UID and render user-level systemd units with the active Python installation.
|
|
16
|
+
- Reuse a parsed per-GPU reservation index, tail-read audit logs, and bound the hot-ledger retention window.
|
|
17
|
+
- Expose GPU model and temperature in privacy-safe Agent and MCP context.
|
|
18
|
+
- Auto-detect visible GPUs when no administrator count is configured, while preserving explicit limits.
|
|
19
|
+
- Keep TUI headers and keyboard hints complete on terminals as narrow as 72 columns.
|
|
20
|
+
- Pin all third-party GitHub Actions to immutable commits and test that release invariant.
|
|
21
|
+
- Fail closed on an unreadable ledger without a valid backup, while still allowing durable journal recovery.
|
|
22
|
+
- Add machine-readable MCP risk annotations for read-only, idempotent, destructive, and closed-world tools.
|
|
23
|
+
- Bind shared ledgers to one scheduling and storage policy so per-user environment overrides cannot silently change capacity rules.
|
|
24
|
+
- Keep ordinary read-only CLI, Agent, and MCP calls free of empty-directory initialization side effects while preserving durable WAL recovery.
|
|
25
|
+
- Reject untrusted shared configuration, symbolic-link and special-file redirection across ledger, audit, and private job paths.
|
|
26
|
+
- Bound external allocator output and terminate its whole process group on timeout or protocol overflow.
|
|
27
|
+
- Adopt Apache-2.0 and publish maintainer and GitHub project metadata for the `gpubk` distribution.
|
|
28
|
+
- Add a paged colorized TUI help center, explicit `f`/`g`/`r` guidance, and an embedded Quick Tour.
|
|
29
|
+
- Center the live timeline around a visible NOW marker, permit read-only reservation history browsing, and keep GPU capacity/utilization/memory columns aligned.
|
|
30
|
+
- Reject edits after a reservation starts or when an exact replacement start is in the past across both TUI and scheduler APIs.
|
|
31
|
+
- Add auto-detected dark/light TUI themes, a live theme toggle, and terminal-default neutral text for readable black and white backgrounds.
|
|
32
|
+
- Normalize editable and installed coverage paths in CI so subprocess data cannot count the same package twice and falsely fail the coverage gate.
|
|
33
|
+
- Make secure-config tests independent of the host umask used on shared lab servers.
|
|
34
|
+
- Show allocatable free VRAM in compact GPU rows and never render partially truncated trailing metrics.
|
|
35
|
+
- Add token-free Trusted Publishing through TestPyPI verification and protected PyPI promotion of one immutable artifact.
|
|
36
|
+
- Add package-structure, metadata, and medium/high-severity static security gates to CI.
|
|
37
|
+
- Replace optimization-sensitive production assertions with explicit fail-closed runtime checks.
|
|
38
|
+
- Keep Agent recommendations and telemetry-history reads side-effect free when the data directory does not exist.
|
|
39
|
+
- Add retry-safe structured Agent and MCP edits, structured Agent cancellation, capability discovery, and operation-intent mismatch rejection.
|
gpubk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
gpubk-0.1.0/MANIFEST.in
ADDED
gpubk-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gpubk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline, load-aware GPU booking CLI, curses TUI, worker, and agent interface.
|
|
5
|
+
Author-email: lzzmm <cortexcyh@gmail.com>
|
|
6
|
+
Maintainer-email: lzzmm <cortexcyh@gmail.com>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/lzzmm/gpubk
|
|
9
|
+
Project-URL: Repository, https://github.com/lzzmm/gpubk
|
|
10
|
+
Project-URL: Issues, https://github.com/lzzmm/gpubk/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/lzzmm/gpubk/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: gpu,scheduler,booking,tui,nvml,mcp,agent
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Environment :: Console :: Curses
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: System Administrators
|
|
18
|
+
Classifier: Operating System :: POSIX
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
26
|
+
Classifier: Topic :: System :: Systems Administration
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Provides-Extra: gpu
|
|
31
|
+
Requires-Dist: nvidia-ml-py>=12; extra == "gpu"
|
|
32
|
+
Provides-Extra: mcp
|
|
33
|
+
Requires-Dist: mcp<2,>=1.28.1; extra == "mcp"
|
|
34
|
+
Provides-Extra: all
|
|
35
|
+
Requires-Dist: nvidia-ml-py>=12; extra == "all"
|
|
36
|
+
Requires-Dist: mcp<2,>=1.28.1; extra == "all"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# GPUbk
|
|
40
|
+
|
|
41
|
+
**English** | [简体中文](https://github.com/lzzmm/gpubk/blob/main/README.zh-CN.md)
|
|
42
|
+
|
|
43
|
+
GPUbk is a GPU booking tool for shared Linux servers. The package is named
|
|
44
|
+
`gpubk`; the command is the shorter `bk`.
|
|
45
|
+
|
|
46
|
+
It works offline, stores data in local files, and has no required runtime
|
|
47
|
+
dependencies. Users can book GPUs from a plain terminal prompt, a curses TUI,
|
|
48
|
+
JSON commands, or an optional local MCP server.
|
|
49
|
+
|
|
50
|
+
## What It Covers
|
|
51
|
+
|
|
52
|
+
- Shared and exclusive reservations in 5-minute intervals.
|
|
53
|
+
- Automatic queueing, live GPU awareness, and per-GPU VRAM budgets.
|
|
54
|
+
- A compact timeline that works on dark and light terminals.
|
|
55
|
+
- Scheduled commands with automatic `CUDA_VISIBLE_DEVICES`.
|
|
56
|
+
- NVML process monitoring and recent-load history.
|
|
57
|
+
- Stable JSON, MCP tools, a bundled Codex Skill, and an optional external allocator.
|
|
58
|
+
- Atomic file transactions, UID ownership checks, backups, and an append-only audit log.
|
|
59
|
+
|
|
60
|
+
GPUbk is a cooperative scheduler. It does not replace Linux device permissions
|
|
61
|
+
or stop a user with direct access to `/dev/nvidia*` from bypassing the tool.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
GPUbk requires Python 3.10 or newer.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
python3 -m pip install gpubk # core CLI and TUI; no dependencies
|
|
69
|
+
python3 -m pip install 'gpubk[gpu]' # add low-overhead NVML telemetry
|
|
70
|
+
python3 -m pip install 'gpubk[mcp]' # add the local MCP server
|
|
71
|
+
python3 -m pip install 'gpubk[all]' # both optional extras
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Verify the installation:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
bk --version
|
|
78
|
+
bk --help
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Book GPUs
|
|
82
|
+
|
|
83
|
+
Shared mode is the default:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
bk 1 30m # one GPU for 30 minutes
|
|
87
|
+
bk 2 1h30m --mem 12g # 12 GiB expected VRAM per GPU
|
|
88
|
+
bk s 1 2h --gpu 3 # explicit shared mode on GPU 3
|
|
89
|
+
bk x 2 4h # exclusive mode
|
|
90
|
+
bk 1 1h --start 2026-07-12T20:00:00+08:00
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Manage your reservations with a list number or short ID:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
bk l
|
|
97
|
+
bk e 1 --duration 2h
|
|
98
|
+
bk d 1
|
|
99
|
+
bk doctor # read-only ledger checks
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Scheduling rules are intentionally small:
|
|
103
|
+
|
|
104
|
+
- Start times and durations use 5-minute boundaries.
|
|
105
|
+
- Without `--start`, GPUbk picks the earliest valid slot and prints `queued:`
|
|
106
|
+
when the reservation starts later.
|
|
107
|
+
- With `--start`, the time is exact. A conflict returns an error instead of
|
|
108
|
+
silently moving the reservation.
|
|
109
|
+
- Shared capacity is counted per overlapping reservation. Exclusive
|
|
110
|
+
reservations cannot overlap anything.
|
|
111
|
+
- `--mem` is expected VRAM **per GPU**. Administrators can require it for all
|
|
112
|
+
shared reservations.
|
|
113
|
+
- Times shown to users are local. The ledger stores UTC.
|
|
114
|
+
|
|
115
|
+
Automatic placement considers reservations, physical free VRAM, current GPU
|
|
116
|
+
processes, recent load, and near-future booking pressure. A process without a
|
|
117
|
+
reservation is reported and avoided when another suitable GPU is free.
|
|
118
|
+
|
|
119
|
+
## Terminal Interfaces
|
|
120
|
+
|
|
121
|
+
`bk` opens a normal line-oriented prompt and keeps the terminal background.
|
|
122
|
+
`bk t` opens the full-screen TUI.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
bk
|
|
126
|
+
bk t
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Useful TUI keys:
|
|
130
|
+
|
|
131
|
+
| Key | Action |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| `a` / `e` / `d` | Add, edit, or cancel a reservation |
|
|
134
|
+
| `Tab`, `↑`, `↓` | Move between reservations and GPU details |
|
|
135
|
+
| `←`, `→` | Browse the timeline; move time in Add/Edit |
|
|
136
|
+
| `Space` | Toggle the current GPU in Add/Edit |
|
|
137
|
+
| `+`, `-` | Change timeline zoom or reservation duration |
|
|
138
|
+
| `1`-`9` | Pick a GPU count and jump to the nearest valid slot |
|
|
139
|
+
| `s`, `x` | Switch between shared and exclusive in Add/Edit |
|
|
140
|
+
| `f`, `g` | Find any suitable GPUs, or keep the selected GPUs fixed |
|
|
141
|
+
| `n` | Return to the live `NOW` window |
|
|
142
|
+
| `c` | Toggle the dark/light theme |
|
|
143
|
+
| `?` | Open the paged help and quick tour |
|
|
144
|
+
| `Enter`, `Esc`, `q` | Submit, cancel the current action, or quit |
|
|
145
|
+
|
|
146
|
+
The timeline can show past reservations, but history is read-only. Add and Edit
|
|
147
|
+
always validate the selected interval again inside the locked scheduler
|
|
148
|
+
transaction.
|
|
149
|
+
|
|
150
|
+
## Run a Command at Reservation Time
|
|
151
|
+
|
|
152
|
+
Put the command after `--`:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
bk 2 1h30m --mem 12g -- python train.py --config exp.yaml
|
|
156
|
+
bk j # list scheduled jobs
|
|
157
|
+
bk w # run this user's due jobs
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The worker sets `CUDA_VISIBLE_DEVICES`, `CUDA_DEVICE_ORDER`,
|
|
161
|
+
`BK_RESERVATION_ID`, and `BK_RESERVED_GPUS`. Commands and working directories
|
|
162
|
+
stay in UID-owned `0600` job specs; they are not written to the shared ledger.
|
|
163
|
+
The worker uses `shell=False`. Use an explicit shell only when shell syntax is
|
|
164
|
+
required:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
bk 1 30m -- sh -lc 'python train.py > train.log 2>&1'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
For unattended jobs, each user can install the bundled systemd user unit:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
bk service install worker
|
|
174
|
+
systemctl --user daemon-reload
|
|
175
|
+
systemctl --user enable --now bk-worker.service
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Monitoring and Placement
|
|
179
|
+
|
|
180
|
+
Install the `gpu` extra, then run a single sample or a low-overhead monitor:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
bk m --once
|
|
184
|
+
bk m
|
|
185
|
+
bk u --rollups
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
NVML is initialized once and device handles are reused. The monitor records
|
|
189
|
+
bounded load summaries plus process start, stop, and authorization changes; it
|
|
190
|
+
does not append a full snapshot every second. Without NVML, GPUbk falls back to
|
|
191
|
+
`nvidia-smi` with less process detail.
|
|
192
|
+
|
|
193
|
+
Process status is based on the process UID and active reservation:
|
|
194
|
+
`ok`, `wrong-gpu`, `unreserved`, `unknown`, or `system`. Command lines are
|
|
195
|
+
reduced to safe labels before shared logging.
|
|
196
|
+
|
|
197
|
+
The monitor also has a user service:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
bk service install monitor
|
|
201
|
+
systemctl --user daemon-reload
|
|
202
|
+
systemctl --user enable --now bk-monitor.service
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Agents and MCP
|
|
206
|
+
|
|
207
|
+
Agents should use the versioned JSON interface instead of parsing terminal text:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
bk agent context --compact
|
|
211
|
+
bk agent recommend 2 1h30m --mem 12g --compact
|
|
212
|
+
bk 2 1h30m --mem 12g --op-id run-20260712-001 --json
|
|
213
|
+
bk agent edit 6e957ef1 --duration 2h --op-id edit-20260712-001 --compact
|
|
214
|
+
bk agent cancel 6e957ef1 --compact
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Create and edit operations require a stable operation ID. An identical retry
|
|
218
|
+
returns `status=exists`; reusing the ID for a different write is rejected.
|
|
219
|
+
Recommendations are read-only. Identity always comes from the local process UID.
|
|
220
|
+
|
|
221
|
+
Run the optional stdio MCP server with:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
bk-mcp # same as: bk mcp
|
|
225
|
+
bk skill install # installs the bundled Codex Skill
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
The MCP server provides context, recommendation, create, list, edit, cancel,
|
|
229
|
+
and private job-log tools. It listens on stdio only; each user runs their own
|
|
230
|
+
process. Tool schemas include read-only, idempotent, destructive, and
|
|
231
|
+
closed-world annotations.
|
|
232
|
+
|
|
233
|
+
An administrator may also set `BK_ALLOCATOR_COMMAND` to a trusted local program
|
|
234
|
+
that reads `bk.allocator.v1` JSON and returns a GPU ordering. Its output is
|
|
235
|
+
advisory: every result still passes the built-in conflict, VRAM, time, UID, and
|
|
236
|
+
transaction checks. See the [Agent protocol](https://github.com/lzzmm/gpubk/blob/main/src/bk/data/codex-skill/gpubk/references/protocol.md).
|
|
237
|
+
|
|
238
|
+
## Shared Server Setup
|
|
239
|
+
|
|
240
|
+
Create one setgid directory for the lab group:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
sudo install -d -m 2770 -o root -g gpuusers /data2/shared/bk
|
|
244
|
+
export BK_DATA_DIR=/data2/shared/bk
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Put a root-owned `config.json` in that directory:
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"gpu_count": 8,
|
|
252
|
+
"max_shared_users": 2,
|
|
253
|
+
"queue_search_hours": 168,
|
|
254
|
+
"ledger_retention_days": 90,
|
|
255
|
+
"require_shared_memory": true,
|
|
256
|
+
"shared_memory_reserve_mb": 512,
|
|
257
|
+
"file_mode": "0660",
|
|
258
|
+
"dir_mode": "2770"
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
sudo chown root:gpuusers /data2/shared/bk/config.json
|
|
264
|
+
sudo chmod 0644 /data2/shared/bk/config.json
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
All users and user services must use the same `BK_DATA_DIR`. The first write
|
|
268
|
+
binds scheduling and storage policy into the ledger; clients with conflicting
|
|
269
|
+
settings fail closed. Verify `flock` and atomic rename on the actual NFS or FUSE
|
|
270
|
+
mount before deployment. Every writer must use GPUbk.
|
|
271
|
+
|
|
272
|
+
See [SECURITY.md](https://github.com/lzzmm/gpubk/blob/main/SECURITY.md) for the supported boundary, file safety, WAL
|
|
273
|
+
recovery, private job specs, MCP isolation, and administrator responsibilities.
|
|
274
|
+
|
|
275
|
+
## Try It Without a GPU
|
|
276
|
+
|
|
277
|
+
Booking and the TUI can run with simulated GPU count:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
BK_DATA_DIR=/tmp/gpubk-demo BK_GPU_COUNT=4 bk t
|
|
281
|
+
BK_DATA_DIR=/tmp/gpubk-demo BK_GPU_COUNT=4 bk 1 30m
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The cards show unknown hardware metrics, but scheduling, shared capacity, the
|
|
285
|
+
timeline, Add/Edit, logs, and Agent JSON remain usable.
|
|
286
|
+
|
|
287
|
+
## Development
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
python3 -m pip install -e '.[mcp,gpu]'
|
|
291
|
+
PYTHONPATH=src python3 -m unittest discover -s tests -p 'test_*.py'
|
|
292
|
+
PYTHONPATH=src python3 benchmarks/scheduler_queue.py
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Project documents: [Security](https://github.com/lzzmm/gpubk/blob/main/SECURITY.md) ·
|
|
296
|
+
[Release process](https://github.com/lzzmm/gpubk/blob/main/RELEASING.md) ·
|
|
297
|
+
[Changelog](https://github.com/lzzmm/gpubk/blob/main/CHANGELOG.md) ·
|
|
298
|
+
[Apache-2.0 license](https://github.com/lzzmm/gpubk/blob/main/LICENSE)
|