-
Notifications
You must be signed in to change notification settings - Fork 113
Make gpu_test binary optional; unblock Nix installs (#498) #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
60d69de
ab2b52a
7442aa8
cc78063
755e424
f90c03a
8f8ef51
727c85d
75db90e
da7415d
96535b5
19dda64
c1e9c6b
f5e5af1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| include runpod/serverless/binaries/gpu_test | ||
| include runpod/serverless/binaries/README.md | ||
| include build_tools/gpu_test.c | ||
| include build_tools/compile_gpu_test.sh | ||
| exclude runpod/serverless/binaries/gpu_test |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """GPU test binary installer CLI.""" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """ | ||
| CLI commands for installing optional runpod binaries. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import click | ||
|
|
||
| import runpod | ||
| from runpod.version import get_version | ||
|
|
||
| from .functions import ( | ||
| BinaryChecksumMismatch, | ||
| BinaryDownloadError, | ||
| download_gpu_test_binary, | ||
| ) | ||
|
|
||
|
|
||
| def _default_install_path() -> Path: | ||
| """Package-local binaries dir — the same path _binary_helpers checks.""" | ||
| return Path(runpod.__file__).parent / "serverless" / "binaries" / "gpu_test" | ||
|
|
||
|
|
||
| @click.command( | ||
| "install-gpu-test", | ||
| help=( | ||
| "Download the optional gpu_test CUDA health-check binary from the " | ||
| "GitHub release matching the installed runpod version. " | ||
| "Runpod GPU workers only — no-op on CPU-only environments." | ||
| ), | ||
| ) | ||
| @click.option( | ||
| "--version", | ||
| "version", | ||
| default=None, | ||
| help="Release tag to download (defaults to installed runpod version).", | ||
| ) | ||
| @click.option( | ||
| "--dest", | ||
| "dest", | ||
| type=click.Path(dir_okay=False, writable=True, path_type=Path), | ||
| default=None, | ||
| help="Override destination path. Defaults to the package's binaries dir.", | ||
| ) | ||
| def install_gpu_test_cli(version: str | None, dest: Path | None) -> None: | ||
| version = version or get_version() | ||
| if version == "unknown": | ||
| click.echo( | ||
| "Cannot determine installed runpod version; pass --version explicitly.", | ||
| err=True, | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
| target = dest or _default_install_path() | ||
|
|
||
| try: | ||
| installed_at = download_gpu_test_binary(version=version, dest=target) | ||
| except (BinaryDownloadError, BinaryChecksumMismatch) as exc: | ||
| click.echo(f"Failed to install gpu_test: {exc}", err=True) | ||
| sys.exit(1) | ||
|
|
||
| click.echo(f"Installed gpu_test at {installed_at}") | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,108 @@ | ||||||
| """ | ||||||
| Download and install the optional gpu_test binary from a GitHub release. | ||||||
|
|
||||||
| The binary is NOT bundled in PyPI wheels to keep them universal | ||||||
| (py3-none-any). Runpod GPU workers that want the native CUDA memory | ||||||
| allocation test can fetch it from the GitHub release matching their | ||||||
| installed runpod version. | ||||||
|
|
||||||
| See docs/serverless/gpu_binary_compilation.md for usage. | ||||||
| """ | ||||||
|
|
||||||
| from __future__ import annotations | ||||||
|
|
||||||
| import hashlib | ||||||
| import os | ||||||
| import tempfile | ||||||
| import urllib.error | ||||||
| import urllib.request | ||||||
| from dataclasses import dataclass | ||||||
| from pathlib import Path | ||||||
|
|
||||||
| GITHUB_REPO = "runpod/runpod-python" | ||||||
| DOWNLOAD_TIMEOUT_SECONDS = 60 | ||||||
|
|
||||||
|
|
||||||
| @dataclass(frozen=True) | ||||||
| class ReleaseAssetUrls: | ||||||
| binary: str | ||||||
| checksum: str | ||||||
|
|
||||||
|
|
||||||
| class BinaryDownloadError(RuntimeError): | ||||||
| """Raised when the binary or checksum cannot be fetched.""" | ||||||
|
|
||||||
|
|
||||||
| class BinaryChecksumMismatch(RuntimeError): | ||||||
| """Raised when the downloaded binary's sha256 does not match the expected value.""" | ||||||
|
|
||||||
|
|
||||||
| def release_asset_urls(version: str) -> ReleaseAssetUrls: | ||||||
| """Build release-asset URLs for a given runpod version. | ||||||
|
|
||||||
| Accepts either '1.9.0' or 'v1.9.0' — the leading 'v' is optional. | ||||||
| """ | ||||||
| clean = version.lstrip("v") | ||||||
|
||||||
| clean = version.lstrip("v") | |
| clean = version[1:] if version.startswith("v") else version |
Copilot
AI
Apr 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_parse_sha256() only checks token length, not that it is valid hex. A 64-character non-hex token will incorrectly pass parsing and then fail later as BinaryChecksumMismatch, which misclassifies the problem. Validate with a hex regex / string.hexdigits check and raise BinaryDownloadError when the checksum file content is malformed.
Check failure
Code scanning / CodeQL
Overly permissive file permissions High
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command help text says this is a "no-op on CPU-only environments", but
install_gpu_test_clialways attempts the download regardless of GPU availability. Either remove that claim from the help text or implement an explicit CPU-only short-circuit so behavior matches the CLI help.