gpucheck-cli 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,177 @@
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
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: gpucheck-cli
3
+ Version: 0.1.0
4
+ Summary: Open-source CLI that health-checks NVIDIA GPUs
5
+ Author: narekkeshishyan
6
+ Author-email: narekkeshishyan <keshishyan01@gmail.com>
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Requires-Dist: pynvml
10
+ Requires-Dist: torch ; extra == 'load'
11
+ Requires-Python: >=3.10
12
+ Project-URL: Homepage, https://gpucheck.dev
13
+ Project-URL: Repository, https://github.com/narek-keshishyan/gpucheck
14
+ Provides-Extra: load
15
+ Description-Content-Type: text/markdown
16
+
17
+ # gpucheck
18
+
19
+ One command that stress-tests an NVIDIA GPU and tells you whether it is healthy, throttling, or degraded.
20
+
21
+ Website: [gpucheck.dev](https://gpucheck.dev) — includes the optional $29 signed certificate for used-GPU listings.
22
+
23
+ It records a short idle baseline, runs a sustained matrix-multiply load, and samples temperature, clocks, power, and throttle reasons the whole time. It then explains what it saw in plain language: thermal throttling, power-limit throttling, memory problems, or throughput well below what that model should deliver.
24
+
25
+ ## Install
26
+
27
+ ```
28
+ uvx --from "gpucheck-cli[load]" gpucheck --quick
29
+ # or
30
+ pip install "gpucheck-cli[load]"
31
+ ```
32
+
33
+ The load generator needs PyTorch with CUDA. It is an optional extra (`[load]`) because torch is large; if you already have a CUDA build of torch installed, plain `pip install gpucheck-cli` is enough. (The PyPI package is `gpucheck-cli`; the installed command is `gpucheck`.) Without torch/CUDA the tool still runs but generates no load (it prints a warning), so performance metrics are left blank.
34
+
35
+ ## Usage
36
+
37
+ ```
38
+ gpucheck # standard run: 60 s baseline, 10 min load
39
+ gpucheck --quick # 30 s baseline, 150 s load
40
+ gpucheck --long # 60 s baseline, 30 min load
41
+ gpucheck --offline # never contacts a server
42
+ gpucheck --dry-run # print exactly what would be uploaded, upload nothing
43
+ gpucheck --yes-upload # upload without the prompt
44
+ gpucheck --server URL # upload server (http or https); default https://gpucheck-api.fly.dev
45
+ gpucheck --json PATH # where to write result.json (default ./gpucheck-result.json)
46
+ gpucheck --certify # use a one-time server challenge so the result can earn a certificate
47
+ ```
48
+
49
+ The result is always written locally to `result.json` first. The tool only reads from the GPU; it does not change any settings. Ctrl-C stops a run at any time; an interrupted run writes no result.json and uploads nothing.
50
+
51
+ ### Upload flow
52
+
53
+ After a run, unless you passed `--offline`, gpucheck asks whether to upload (to `https://gpucheck-api.fly.dev` unless you pass `--server URL`). If you say yes you get a result page URL, a grade such as `Grade B — delivers 94.1% of a healthy <model> (n=12, low confidence)` (or the reason there is none, for example "insufficient reference (n=X)" while too few comparable runs exist, or "measurements only" for MIG), and a delete token. Save the token: it is the only way to delete the page later.
54
+
55
+ ```
56
+ curl -X DELETE -H "X-Delete-Token: <token>" <server>/v1/runs/<run_id>
57
+ ```
58
+
59
+ ## What gets uploaded
60
+
61
+ Nothing, unless you opt in. Uploading is off in non-interactive shells unless you pass `--yes-upload`. `--dry-run` prints the exact payload so you can read it first.
62
+
63
+ The payload is the contents of `result.json`: GPU model and driver details, measurements, findings, and the time series of samples. The GPU identifier is replaced by a salted-hash UUID, so the raw serial is never sent. The salt is a public constant in this source code, so anyone who already knows your GPU's UUID can recompute the hash and recognise your card.
64
+
65
+ Result pages are public to anyone with the link, and the server also serves back the full uploaded JSON (every field above, including the sample time series) at `/v1/runs/<run_id>`. The run ID is derived from the content, and the server returns a delete token (stored only as a hash) that lets you remove your page.
66
+
67
+ ## Certificates (`--certify`)
68
+
69
+ `gpucheck --certify` asks the server for a one-time challenge, runs the workload the server prescribes (a set of matrix sizes and an execution order) instead of the default one, and uploads the result with the challenge attached. If the run qualifies, the result page offers a signed certificate for it. Certifying a run is a separate purchase, made on the result page.
70
+
71
+ What you need:
72
+
73
+ - A server that has certification turned on. The default server is `https://gpucheck-api.fly.dev`; pass `--server URL` for another one. If the challenge cannot be fetched (the server has certification turned off, or cannot be reached), gpucheck stops before the run with a message and exit code 1.
74
+ - Working PyTorch with CUDA. Without it, `--certify` stops with exit code 1 instead of falling back to a run with no load.
75
+ - The normal upload prompt still applies. A certificate can only be made from an uploaded result, so answer yes, or pass `--yes-upload` in a script.
76
+
77
+ `--certify` cannot be combined with `--offline`, `--dry-run`, or `--quick`; the argument parser rejects the combination at startup. Certificates need a full-length run (at least 600 s of load), so a quick run could never earn one.
78
+
79
+ If the challenge expires before the run finishes (challenges are valid for 2 hours), gpucheck prints one warning, `challenge expired before upload; run again to certify — result saved locally`, does not upload, and exits normally. The result is still written to the `--json` path.
80
+
81
+ Fake mode: `--fake` with `--certify` runs mechanically, but a real server rejects it with "upload arrived too soon after challenge", because the simulated run finishes instantly. This is intended: fakes cannot earn certificates.
82
+
83
+ After a `--certify` upload, gpucheck prints the server's verdict: `Certifiable: yes`, or `Not certifiable: <reason>` with the reason the server gave (`certify_note`). If the server refuses to certify a run, the upload still succeeds and the result is still stored; the run simply gets no purchase button. A certifiable run also needs a grade, a complete (not aborted, not quarantined) load phase, and a card identity before the result page offers a certificate.
84
+
85
+ ### What a certificate proves
86
+
87
+ A certificate raises the cost of lying about a GPU. It is not proof of anything on its own.
88
+
89
+ - The run used a fresh one-time server challenge and could not be uploaded before the full run time had passed. The uploaded result echoes the challenge's workload parameters, but the server cannot see whether that workload actually ran.
90
+ - The signed payload binds that certificate to one stored result (by its SHA-256), one card (its salted-hash identifier, the same one in the uploaded result), one grade, and one run.
91
+ - Certificates issued while the server is in payment test mode carry a TEST banner and `livemode: false` in the signed payload. They are not real purchases.
92
+
93
+ ### What a certificate does not prove
94
+
95
+ - It does not show that the card is healthy or will stay healthy. A single run is a snapshot, as described under Limitations.
96
+ - It does not stop someone who controls the machine. Someone with full control can fabricate telemetry that matches the prescribed workload and timing. The server cannot see the hardware directly.
97
+ - It does not stop re-running. A card owner can keep running until a run looks good and then buy a certificate for that one. When a newer certificate is issued for the same card, the older one is marked as superseded, which makes this visible, but it is not prevented.
98
+ - Revocation is not part of the signature. A revoked certificate still verifies offline; only the live verify endpoint knows about revocation.
99
+
100
+ Verifying a certificate offline needs the certificate payload, its signature, and the public key from `/v1/pubkey`. The exact steps and a one-line Python check are on the server's `/verify` page and in the server's README.
101
+
102
+ ## Exit codes
103
+
104
+ | Code | Meaning |
105
+ | --- | --- |
106
+ | 0 | Run completed |
107
+ | 1 | Preflight refused to run (for example the GPU is busy) |
108
+ | 2 | No NVIDIA GPU or driver available |
109
+ | 3 | Run aborted partway (thermal limit, ECC errors, or lost telemetry); result.json is still written |
110
+
111
+ ## Limitations
112
+
113
+ - NVIDIA GPUs on Linux only.
114
+ - MIG instances give measurements only; they are not graded.
115
+ - Needs PyTorch with CUDA to generate load; without it, performance numbers are blank.
116
+ - It refuses to run on a GPU that is already busy.
117
+ - Grades depend on a reference set of comparable runs; for new or rare models you will see "insufficient reference".
118
+ - A single run is a snapshot. A healthy result does not guarantee the card will never fail.
119
+
120
+ ## License
121
+
122
+ Apache-2.0
@@ -0,0 +1,106 @@
1
+ # gpucheck
2
+
3
+ One command that stress-tests an NVIDIA GPU and tells you whether it is healthy, throttling, or degraded.
4
+
5
+ Website: [gpucheck.dev](https://gpucheck.dev) — includes the optional $29 signed certificate for used-GPU listings.
6
+
7
+ It records a short idle baseline, runs a sustained matrix-multiply load, and samples temperature, clocks, power, and throttle reasons the whole time. It then explains what it saw in plain language: thermal throttling, power-limit throttling, memory problems, or throughput well below what that model should deliver.
8
+
9
+ ## Install
10
+
11
+ ```
12
+ uvx --from "gpucheck-cli[load]" gpucheck --quick
13
+ # or
14
+ pip install "gpucheck-cli[load]"
15
+ ```
16
+
17
+ The load generator needs PyTorch with CUDA. It is an optional extra (`[load]`) because torch is large; if you already have a CUDA build of torch installed, plain `pip install gpucheck-cli` is enough. (The PyPI package is `gpucheck-cli`; the installed command is `gpucheck`.) Without torch/CUDA the tool still runs but generates no load (it prints a warning), so performance metrics are left blank.
18
+
19
+ ## Usage
20
+
21
+ ```
22
+ gpucheck # standard run: 60 s baseline, 10 min load
23
+ gpucheck --quick # 30 s baseline, 150 s load
24
+ gpucheck --long # 60 s baseline, 30 min load
25
+ gpucheck --offline # never contacts a server
26
+ gpucheck --dry-run # print exactly what would be uploaded, upload nothing
27
+ gpucheck --yes-upload # upload without the prompt
28
+ gpucheck --server URL # upload server (http or https); default https://gpucheck-api.fly.dev
29
+ gpucheck --json PATH # where to write result.json (default ./gpucheck-result.json)
30
+ gpucheck --certify # use a one-time server challenge so the result can earn a certificate
31
+ ```
32
+
33
+ The result is always written locally to `result.json` first. The tool only reads from the GPU; it does not change any settings. Ctrl-C stops a run at any time; an interrupted run writes no result.json and uploads nothing.
34
+
35
+ ### Upload flow
36
+
37
+ After a run, unless you passed `--offline`, gpucheck asks whether to upload (to `https://gpucheck-api.fly.dev` unless you pass `--server URL`). If you say yes you get a result page URL, a grade such as `Grade B — delivers 94.1% of a healthy <model> (n=12, low confidence)` (or the reason there is none, for example "insufficient reference (n=X)" while too few comparable runs exist, or "measurements only" for MIG), and a delete token. Save the token: it is the only way to delete the page later.
38
+
39
+ ```
40
+ curl -X DELETE -H "X-Delete-Token: <token>" <server>/v1/runs/<run_id>
41
+ ```
42
+
43
+ ## What gets uploaded
44
+
45
+ Nothing, unless you opt in. Uploading is off in non-interactive shells unless you pass `--yes-upload`. `--dry-run` prints the exact payload so you can read it first.
46
+
47
+ The payload is the contents of `result.json`: GPU model and driver details, measurements, findings, and the time series of samples. The GPU identifier is replaced by a salted-hash UUID, so the raw serial is never sent. The salt is a public constant in this source code, so anyone who already knows your GPU's UUID can recompute the hash and recognise your card.
48
+
49
+ Result pages are public to anyone with the link, and the server also serves back the full uploaded JSON (every field above, including the sample time series) at `/v1/runs/<run_id>`. The run ID is derived from the content, and the server returns a delete token (stored only as a hash) that lets you remove your page.
50
+
51
+ ## Certificates (`--certify`)
52
+
53
+ `gpucheck --certify` asks the server for a one-time challenge, runs the workload the server prescribes (a set of matrix sizes and an execution order) instead of the default one, and uploads the result with the challenge attached. If the run qualifies, the result page offers a signed certificate for it. Certifying a run is a separate purchase, made on the result page.
54
+
55
+ What you need:
56
+
57
+ - A server that has certification turned on. The default server is `https://gpucheck-api.fly.dev`; pass `--server URL` for another one. If the challenge cannot be fetched (the server has certification turned off, or cannot be reached), gpucheck stops before the run with a message and exit code 1.
58
+ - Working PyTorch with CUDA. Without it, `--certify` stops with exit code 1 instead of falling back to a run with no load.
59
+ - The normal upload prompt still applies. A certificate can only be made from an uploaded result, so answer yes, or pass `--yes-upload` in a script.
60
+
61
+ `--certify` cannot be combined with `--offline`, `--dry-run`, or `--quick`; the argument parser rejects the combination at startup. Certificates need a full-length run (at least 600 s of load), so a quick run could never earn one.
62
+
63
+ If the challenge expires before the run finishes (challenges are valid for 2 hours), gpucheck prints one warning, `challenge expired before upload; run again to certify — result saved locally`, does not upload, and exits normally. The result is still written to the `--json` path.
64
+
65
+ Fake mode: `--fake` with `--certify` runs mechanically, but a real server rejects it with "upload arrived too soon after challenge", because the simulated run finishes instantly. This is intended: fakes cannot earn certificates.
66
+
67
+ After a `--certify` upload, gpucheck prints the server's verdict: `Certifiable: yes`, or `Not certifiable: <reason>` with the reason the server gave (`certify_note`). If the server refuses to certify a run, the upload still succeeds and the result is still stored; the run simply gets no purchase button. A certifiable run also needs a grade, a complete (not aborted, not quarantined) load phase, and a card identity before the result page offers a certificate.
68
+
69
+ ### What a certificate proves
70
+
71
+ A certificate raises the cost of lying about a GPU. It is not proof of anything on its own.
72
+
73
+ - The run used a fresh one-time server challenge and could not be uploaded before the full run time had passed. The uploaded result echoes the challenge's workload parameters, but the server cannot see whether that workload actually ran.
74
+ - The signed payload binds that certificate to one stored result (by its SHA-256), one card (its salted-hash identifier, the same one in the uploaded result), one grade, and one run.
75
+ - Certificates issued while the server is in payment test mode carry a TEST banner and `livemode: false` in the signed payload. They are not real purchases.
76
+
77
+ ### What a certificate does not prove
78
+
79
+ - It does not show that the card is healthy or will stay healthy. A single run is a snapshot, as described under Limitations.
80
+ - It does not stop someone who controls the machine. Someone with full control can fabricate telemetry that matches the prescribed workload and timing. The server cannot see the hardware directly.
81
+ - It does not stop re-running. A card owner can keep running until a run looks good and then buy a certificate for that one. When a newer certificate is issued for the same card, the older one is marked as superseded, which makes this visible, but it is not prevented.
82
+ - Revocation is not part of the signature. A revoked certificate still verifies offline; only the live verify endpoint knows about revocation.
83
+
84
+ Verifying a certificate offline needs the certificate payload, its signature, and the public key from `/v1/pubkey`. The exact steps and a one-line Python check are on the server's `/verify` page and in the server's README.
85
+
86
+ ## Exit codes
87
+
88
+ | Code | Meaning |
89
+ | --- | --- |
90
+ | 0 | Run completed |
91
+ | 1 | Preflight refused to run (for example the GPU is busy) |
92
+ | 2 | No NVIDIA GPU or driver available |
93
+ | 3 | Run aborted partway (thermal limit, ECC errors, or lost telemetry); result.json is still written |
94
+
95
+ ## Limitations
96
+
97
+ - NVIDIA GPUs on Linux only.
98
+ - MIG instances give measurements only; they are not graded.
99
+ - Needs PyTorch with CUDA to generate load; without it, performance numbers are blank.
100
+ - It refuses to run on a GPU that is already busy.
101
+ - Grades depend on a reference set of comparable runs; for new or rare models you will see "insufficient reference".
102
+ - A single run is a snapshot. A healthy result does not guarantee the card will never fail.
103
+
104
+ ## License
105
+
106
+ Apache-2.0
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "gpucheck-cli"
3
+ version = "0.1.0"
4
+ description = "Open-source CLI that health-checks NVIDIA GPUs"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "narekkeshishyan", email = "keshishyan01@gmail.com" }
10
+ ]
11
+ requires-python = ">=3.10"
12
+ dependencies = ["pynvml"]
13
+
14
+ [project.optional-dependencies]
15
+ load = ["torch"]
16
+
17
+ [project.urls]
18
+ Homepage = "https://gpucheck.dev"
19
+ Repository = "https://github.com/narek-keshishyan/gpucheck"
20
+
21
+ [project.scripts]
22
+ gpucheck = "gpucheck.cli:main"
23
+
24
+ [dependency-groups]
25
+ dev = ["pytest"]
26
+
27
+ [build-system]
28
+ requires = ["uv_build>=0.11.6,<0.12.0"]
29
+ build-backend = "uv_build"
30
+
31
+ [tool.uv.build-backend]
32
+ # Distribution is gpucheck-cli (the bare name is taken on PyPI); import package stays gpucheck.
33
+ module-name = "gpucheck"
@@ -0,0 +1 @@
1
+ """gpucheck: health-check NVIDIA GPUs."""
@@ -0,0 +1,192 @@
1
+ """Telemetry types and the adapter protocol, plus the real NVML adapter.
2
+
3
+ All NVML access here is read-only: no NVML setter is ever called.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import hashlib
9
+ import time
10
+ import warnings
11
+ from dataclasses import dataclass
12
+ from typing import Protocol
13
+
14
+
15
+ class AdapterUnavailable(Exception):
16
+ """Raised when no GPU or NVIDIA driver is available."""
17
+
18
+
19
+ @dataclass(frozen=True)
20
+ class GpuInventory:
21
+ model_name: str
22
+ uuid_hash: str
23
+ driver: str
24
+ cuda: str | None
25
+ ecc_enabled: bool | None
26
+ power_limit_w: float | None
27
+ default_power_limit_w: float | None
28
+ mig_enabled: bool
29
+ fractional: bool
30
+ retired_pages: int | None
31
+ remapped_rows: int | None # correctable + uncorrectable
32
+ row_remap_pending: bool | None = None
33
+ row_remap_failure: bool | None = None
34
+
35
+
36
+ @dataclass(frozen=True)
37
+ class TelemetrySample:
38
+ t_s: float
39
+ temp_c: float | None
40
+ power_w: float | None
41
+ sm_clock_mhz: float | None
42
+ fan_pct: float | None
43
+ throttle_reasons: frozenset[str] | None # None = NVML could not report reasons (unknown)
44
+ ecc_volatile: int | None
45
+ achieved_tflops: float | None
46
+
47
+
48
+ class TelemetryAdapter(Protocol):
49
+ def inventory(self) -> GpuInventory: ...
50
+
51
+ def sample(self) -> TelemetrySample: ...
52
+
53
+ def busy(self) -> bool | None: ...
54
+
55
+
56
+ def hash_uuid(uuid: str) -> str:
57
+ return hashlib.sha256(("gpucheck.v1." + uuid).encode()).hexdigest()[:16]
58
+
59
+
60
+ def _text(value: object) -> str:
61
+ return value.decode() if isinstance(value, bytes) else str(value)
62
+
63
+
64
+ def _try(fn, *args):
65
+ """Call an NVML query; None if the GPU does not support it."""
66
+ try:
67
+ return fn(*args)
68
+ except Exception:
69
+ return None
70
+
71
+
72
+ # NVML ABI values, used only when pynvml exposes neither naming family.
73
+ _ABI = {
74
+ "SwPowerCap": 0x4,
75
+ "SwThermalSlowdown": 0x20,
76
+ "HwThermalSlowdown": 0x40,
77
+ "HwPowerBrakeSlowdown": 0x80,
78
+ }
79
+
80
+
81
+ def _const(nv, *names: str, default: int) -> int:
82
+ """First of `names` that pynvml defines, else `default`; never raises."""
83
+ for name in names:
84
+ value = getattr(nv, name, None)
85
+ if isinstance(value, int):
86
+ return value
87
+ return default
88
+
89
+
90
+ def _reason_bit(nv, suffix: str) -> int:
91
+ # pynvml renamed "ClocksThrottleReason" to "ClocksEventReason" (NVML 12.x); the
92
+ # upper-case NVML_CLOCKS_THROTTLE_REASON_* spelling never existed in pynvml.
93
+ return _const(
94
+ nv,
95
+ f"nvmlClocksEventReason{suffix}",
96
+ f"nvmlClocksThrottleReason{suffix}",
97
+ default=_ABI[suffix],
98
+ )
99
+
100
+
101
+ class NvmlAdapter(TelemetryAdapter):
102
+ """Reads GPU 0 through NVML (pynvml)."""
103
+
104
+ def __init__(self, index: int = 0) -> None:
105
+ try:
106
+ with warnings.catch_warnings():
107
+ warnings.simplefilter("ignore", FutureWarning) # pynvml deprecation notice
108
+ import pynvml
109
+
110
+ pynvml.nvmlInit()
111
+ self._nv = pynvml
112
+ self._h = pynvml.nvmlDeviceGetHandleByIndex(index)
113
+ except Exception as exc: # ImportError, NVMLError, missing library...
114
+ raise AdapterUnavailable(f"NVML unavailable: {exc}") from exc
115
+ self._t0 = time.monotonic()
116
+
117
+ def _q(self, name: str, *args):
118
+ """Optional NVML query by name: None if pynvml lacks it or the GPU does not support it."""
119
+ fn = getattr(self._nv, name, None)
120
+ return None if fn is None else _try(fn, *args)
121
+
122
+ def inventory(self) -> GpuInventory:
123
+ nv, h = self._nv, self._h
124
+ uuid = _text(nv.nvmlDeviceGetUUID(h))
125
+ cuda_raw = self._q("nvmlSystemGetCudaDriverVersion")
126
+ cuda = f"{cuda_raw // 1000}.{(cuda_raw % 1000) // 10}" if cuda_raw else None
127
+ ecc = self._q("nvmlDeviceGetEccMode", h)
128
+ limit = self._q("nvmlDeviceGetPowerManagementLimit", h)
129
+ default = self._q("nvmlDeviceGetPowerManagementDefaultLimit", h)
130
+ mig = self._q("nvmlDeviceGetMigMode", h)
131
+ cause = _const(nv, "NVML_PAGE_RETIREMENT_CAUSE_MULTIPLE_SINGLE_BIT_ECC_ERRORS", default=0)
132
+ retired = self._q("nvmlDeviceGetRetiredPages", h, cause)
133
+ # (correctable rows, uncorrectable rows, remap pending, remap failure occurred)
134
+ remap = self._q("nvmlDeviceGetRemappedRows", h)
135
+ remap_ok = isinstance(remap, (tuple, list)) and len(remap) >= 4
136
+ return GpuInventory(
137
+ model_name=_text(nv.nvmlDeviceGetName(h)),
138
+ uuid_hash=hash_uuid(uuid),
139
+ driver=_text(nv.nvmlSystemGetDriverVersion()),
140
+ cuda=cuda,
141
+ ecc_enabled=bool(ecc[0]) if ecc else None,
142
+ power_limit_w=limit / 1000.0 if limit is not None else None,
143
+ default_power_limit_w=default / 1000.0 if default is not None else None,
144
+ mig_enabled=bool(mig and mig[0]),
145
+ fractional=False,
146
+ retired_pages=len(retired) if retired is not None else None,
147
+ remapped_rows=int(remap[0]) + int(remap[1]) if remap_ok else None,
148
+ row_remap_pending=bool(remap[2]) if remap_ok else None,
149
+ row_remap_failure=bool(remap[3]) if remap_ok else None,
150
+ )
151
+
152
+ def _throttle_mask(self) -> int | None:
153
+ for name in ("nvmlDeviceGetCurrentClocksEventReasons", "nvmlDeviceGetCurrentClocksThrottleReasons"):
154
+ mask = self._q(name, self._h)
155
+ if mask is not None:
156
+ return int(mask)
157
+ return None # unknown: recorded as a telemetry gap, never as "no throttling"
158
+
159
+ def sample(self) -> TelemetrySample:
160
+ nv, h = self._nv, self._h
161
+ temp = self._q("nvmlDeviceGetTemperature", h, _const(nv, "NVML_TEMPERATURE_GPU", default=0))
162
+ power = self._q("nvmlDeviceGetPowerUsage", h)
163
+ clock = self._q("nvmlDeviceGetClockInfo", h, _const(nv, "NVML_CLOCK_SM", default=1))
164
+ fan = self._q("nvmlDeviceGetFanSpeed", h)
165
+ mask = self._throttle_mask()
166
+ ecc = self._q(
167
+ "nvmlDeviceGetTotalEccErrors",
168
+ h,
169
+ _const(nv, "NVML_MEMORY_ERROR_TYPE_UNCORRECTED", default=1),
170
+ _const(nv, "NVML_VOLATILE_ECC", default=0),
171
+ )
172
+ reasons: frozenset[str] | None = None
173
+ if mask is not None:
174
+ names = {
175
+ "thermal": _reason_bit(nv, "HwThermalSlowdown") | _reason_bit(nv, "SwThermalSlowdown"),
176
+ "power": _reason_bit(nv, "SwPowerCap") | _reason_bit(nv, "HwPowerBrakeSlowdown"),
177
+ }
178
+ reasons = frozenset(name for name, bits in names.items() if mask & bits)
179
+ return TelemetrySample(
180
+ t_s=time.monotonic() - self._t0,
181
+ temp_c=float(temp) if temp is not None else None,
182
+ power_w=power / 1000.0 if power is not None else None,
183
+ sm_clock_mhz=float(clock) if clock is not None else None,
184
+ fan_pct=float(fan) if fan is not None else None,
185
+ throttle_reasons=reasons,
186
+ ecc_volatile=int(ecc) if ecc is not None else None,
187
+ achieved_tflops=None, # supplied by the load generator, not NVML
188
+ )
189
+
190
+ def busy(self) -> bool | None:
191
+ procs = self._q("nvmlDeviceGetComputeRunningProcesses", self._h)
192
+ return None if procs is None else len(procs) > 0